@Override public PolicyDTO getPolicy(String policyId, String version) throws EntitlementException { // Zero means current version if (version == null || version.trim().length() == 0) { Registry registry = EntitlementServiceComponent. getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId()); try { Collection collection = (Collection) registry. get(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId); if (collection != null) { version = collection.getProperty("version"); } } catch (RegistryException e) { log.error(e); throw new EntitlementException("Invalid policy version"); } } PAPPolicyStore policyStore = new PAPPolicyStore(); PAPPolicyStoreReader reader = new PAPPolicyStoreReader(policyStore); Resource resource = policyStore.getPolicy(version, PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId + RegistryConstants.PATH_SEPARATOR); if (resource == null) { throw new EntitlementException("Invalid policy version"); } return reader.readPolicyDTO(resource); }
@Override public PolicyDTO getPolicy(String policyId, String version) throws EntitlementException { // Zero means current version if (version == null || version.trim().length() == 0) { Registry registry = EntitlementServiceComponent. getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId()); try { Collection collection = (Collection) registry. get(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId); if (collection != null) { version = collection.getProperty("version"); } } catch (RegistryException e) { log.error(e); throw new EntitlementException("Invalid policy version"); } } PAPPolicyStore policyStore = new PAPPolicyStore(); PAPPolicyStoreReader reader = new PAPPolicyStoreReader(policyStore); Resource resource = policyStore.getPolicy(version, PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId + RegistryConstants.PATH_SEPARATOR); if (resource == null) { throw new EntitlementException("Invalid policy version"); } return reader.readPolicyDTO(resource); }
@Override public PolicyDTO getPolicy(String policyId, String version) throws EntitlementException { // Zero means current version if (version == null || version.trim().length() == 0) { Registry registry = EntitlementServiceComponent. getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId()); try { Collection collection = (Collection) registry. get(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId); if (collection != null) { version = collection.getProperty("version"); } } catch (RegistryException e) { log.error(e); throw new EntitlementException("Invalid policy version"); } } PAPPolicyStore policyStore = new PAPPolicyStore(); PAPPolicyStoreReader reader = new PAPPolicyStoreReader(policyStore); Resource resource = policyStore.getPolicy(version, PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId + RegistryConstants.PATH_SEPARATOR); if (resource == null) { throw new EntitlementException("Invalid policy version"); } return reader.readPolicyDTO(resource); }
version = collection.getProperty("version"); } else { collection = registry.newCollection();
version = collection.getProperty("version"); } else { collection = registry.newCollection();
version = collection.getProperty("version"); } else { collection = registry.newCollection();