@Override public void deletePolicy(String policyId) throws EntitlementException { Registry registry = EntitlementServiceComponent. getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId()); try { if (registry.resourceExists(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId)) { registry.delete(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId); } } catch (RegistryException e) { log.error("Error while deleting all versions of policy", e); } }
@Override public void deletePolicy(String policyId) throws EntitlementException { Registry registry = EntitlementServiceComponent. getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId()); try { if (registry.resourceExists(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId)) { registry.delete(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId); } } catch (RegistryException e) { log.error("Error while deleting all versions of policy", e); } }
@Override public void deletePolicy(String policyId) throws EntitlementException { Registry registry = EntitlementServiceComponent. getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId()); try { if (registry.resourceExists(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId)) { registry.delete(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId); } } catch (RegistryException e) { log.error("Error while deleting all versions of policy", e); } }
/** * * Populates the properties using the configuration file in the given registry location. * * @param configResourcePath * @param registry */ public void populate(String configResourcePath, Registry registry){ try{ if(registry.resourceExists(configResourcePath)) { Resource configurationsResource = registry.get(configResourcePath); StAXOMBuilder builder = new StAXOMBuilder(configurationsResource.getContentStream()); OMElement root = builder.getDocumentElement(); populate(root); } } catch (XMLStreamException e) { String errorMessage = "Can't load the tenant configuration for the tenant " + tenantID; log.error(errorMessage, e); } catch (RegistryException e) { String errorMessage = "Can't load the tenant configuration for the tenant " + tenantID; log.error(errorMessage, e); } }
/** * Load Analytics profile from given registry and registry path. * * @param analyticsServerProfile AnalyticsServerProfile instance * @param registry Registry space where file is located * @param location Registry path of the profile file */ private void loadAnalyticsProfileFromRegistry(AnalyticsServerProfile analyticsServerProfile, Registry registry, String location) { try { if (registry.resourceExists(location)) { Resource resource = registry.get(location); String resourceContent = new String((byte[]) resource.getContent()); parseAnalyticsProfile(resourceContent, analyticsServerProfile); } else { String errMsg = "The resource: " + location + " does not exist."; handleError(errMsg); } } catch (RegistryException e) { String errMsg = "Error occurred while reading the resource from registry: " + location + " to build the Analytics server profile: " + profileLocation; handleError(errMsg, e); } }
/** * Delete the resource * * @param applicationName * @throws IdentityApplicationManagementException */ public static void deletePermissions(String applicationName) throws IdentityApplicationManagementException { String applicationNode = getApplicationPermissionPath() + PATH_CONSTANT + applicationName; Registry tenantGovReg = CarbonContext.getThreadLocalCarbonContext().getRegistry( RegistryType.USER_GOVERNANCE); try { boolean exist = tenantGovReg.resourceExists(applicationNode); if (exist) { tenantGovReg.delete(applicationNode); } } catch (RegistryException e) { throw new IdentityApplicationManagementException("Error while storing permissions", e); } }
/** * Delete the resource * * @param applicationName * @throws IdentityApplicationManagementException */ public static void deletePermissions(String applicationName) throws IdentityApplicationManagementException { String applicationNode = getApplicationPermissionPath() + PATH_CONSTANT + applicationName; Registry tenantGovReg = CarbonContext.getThreadLocalCarbonContext().getRegistry( RegistryType.USER_GOVERNANCE); try { boolean exist = tenantGovReg.resourceExists(applicationNode); if (exist) { tenantGovReg.delete(applicationNode); } } catch (RegistryException e) { throw new IdentityApplicationManagementException("Error while storing permissions", e); } }
if (registry.resourceExists(path)) { registry.delete(path);
if (registry.resourceExists(path)) { registry.delete(path);
private void buildUIPermissionNodeAllSelected(Collection parent, UIPermissionNode parentNode, Registry registry, Registry tenantRegistry) throws RegistryException, UserStoreException { String[] children = parent.getChildren(); UIPermissionNode[] childNodes = new UIPermissionNode[children.length]; for (int i = 0; i < children.length; i++) { String child = children[i]; Resource resource = null; if (registry.resourceExists(child)) { resource = registry.get(child); } else if (tenantRegistry != null) { resource = tenantRegistry.get(child); } else { throw new RegistryException("Permission resource not found in the registry."); } childNodes[i] = getUIPermissionNode(resource, true); if (resource instanceof Collection) { buildUIPermissionNodeAllSelected((Collection) resource, childNodes[i], registry, tenantRegistry); } } parentNode.setNodeList(childNodes); }
} else if (registry.resourceExists(child)) { resource = registry.get(child); } else {
private void buildUIPermissionNodeAllSelected(Collection parent, UIPermissionNode parentNode, Registry registry, Registry tenantRegistry) throws RegistryException, UserStoreException { String[] children = parent.getChildren(); UIPermissionNode[] childNodes = new UIPermissionNode[children.length]; for (int i = 0; i < children.length; i++) { String child = children[i]; Resource resource = null; if (registry.resourceExists(child)) { resource = registry.get(child); } else if (tenantRegistry != null) { resource = tenantRegistry.get(child); } else { throw new RegistryException("Permission resource not found in the registry."); } childNodes[i] = getUIPermissionNode(resource, true); if (resource instanceof Collection) { buildUIPermissionNodeAllSelected((Collection) resource, childNodes[i], registry, tenantRegistry); } } parentNode.setNodeList(childNodes); }
} else if (registry.resourceExists(child)) { resource = registry.get(child); } else {
boolean exist = tenantGovReg.resourceExists(applicationNode);
boolean exist = tenantGovReg.resourceExists(applicationNode);
if (registry.resourceExists(policyPath + olderVersion)) { registry.delete(policyPath + olderVersion);
Collection appRoot; if (tenentRegistry.resourceExists(APPLICATIONS_PATH)) { appRoot = (Collection) tenentRegistry.get(APPLICATIONS_PATH); parent = (Collection) tenentRegistry.newCollection();
boolean exist = tenantGovReg.resourceExists(applicationNode); if (!exist) { Collection appRootNode = tenantGovReg.newCollection();
boolean exist = tenantGovReg.resourceExists(applicationNode); if (!exist) { Collection appRootNode = tenantGovReg.newCollection();
.getRegistry(RegistryType.USER_GOVERNANCE); boolean exist = tenantGovReg.resourceExists(applicationNode); if (exist && !StringUtils.equals(storedAppName, serviceProvider.getApplicationName())) { ApplicationMgtUtil.renameAppPermissionPathNode(storedAppName, serviceProvider.getApplicationName());