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
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to