Hi, By getting the super tenant's registry as below and use the relative resource path worked for me.
Registry registry = registryService.getGovernanceSystemRegistry(); path = /apimgt/applicationdata/tenant_tier_policies.xml Thanks for the support Danesh. Ishara Cooray Senior Software Engineer Mobile : +9477 262 9512 WSO2, Inc. | http://wso2.com/ Lean . Enterprise . Middleware On Wed, Dec 16, 2015 at 12:15 PM, Ishara Cooray <isha...@wso2.com> wrote: > I have a .xml policy file stored in super tenant's registry. I need to > read the file only once at the bundle activation. > > I was trying following approaches but none of them give me the resource i > am looking for. > > 1. > > > > > > > > * RegistryService registryService = > ThrottleDataHolder.getRegistryService(); Registry registry = > null; try { registry = > registryService.getGovernanceSystemRegistry(Constants.SUPER_TENANT_ID); > } catch (RegistryException e) { log.error("Error while fetching > Governance Registry of Super Tenant"); }* > > * String path = > "gov:/apimgt/applicationdata/tenant_tier_policies.xml";* > > > > > > > * try { if (registry.resourceExists(path)) > { return registry.get(path); } > } catch (RegistryException e) { log.error("Error while > fetching the resource " + path, e); }* > > In this case resourceExists returns false. > > 2. > > > > * Registry governanceRegistry = > getSuperTenantRegistry();//as above PolicyManager > policyManager = new PolicyManager(governanceRegistry); > Policy policy = policyManager.getPolicy(Constants.POLICY_KEY); * > In this case policy is null. > > 3. > > > > > > > > > > > > > > > > > > > > * String url = "https://192.168.123.100:9443/registry > <https://192.168.123.100:9443/registry>"; String username = > Constants.SUPER_USER_NAME; String password = > Constants.SUPER_USER_PW; > System.setProperty(Constants.CARBON_REPO_WRITE_MODE, "true"); > Registry rootRegistry = null; try { rootRegistry > = new RemoteRegistry(new URL(url), username, password); } catch > (RegistryException e) { e.printStackTrace(); } > catch (MalformedURLException e) { > e.printStackTrace(); } String policyContent = > null; OMElement policyElement = null; try { > PolicyManager policyManager = new > PolicyManager(rootRegistry); Policy policy = > policyManager.getPolicy(Constants.POLICY_KEY);// get the OM > from the policy. policyContent = policy.getPolicyContent();* > > In this case it hangs at policyManager.getPolicy(Constants.POLICY_KEY); > > Wondering what is the proper way of doing this. > Any help would be appreciated. > > Thanks. > Ishara Cooray >
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev