Hi Viduranga,

It seems you are trying to access a resource stored in the config registry
space. So you have to use *"getConfigUserRegistry"* method and your
registry resource path should be
"/apimgt/applicationdata/tenant-conf.json"(Need to omit "/_system/config
part).

Regards,
Chandana

Blog: http://blog.napagoda.com
Linkedin: https://www.linkedin.com/in/chandananapagoda/

On 8 December 2017 at 19:37, Viduranga Gunarathne <vidura...@wso2.com>
wrote:

> Hi,
> @Praminda and @Prasanna thank you for the tips.
>
> However when I tried accessing the registry in the following way the below
> mentioned errors occur.
>
> *Code:*
> var registry = carbon.server.osgiService('org
> .wso2.carbon.registry.core.service.RegistryService').getGovernanceUserRegistry(provider,
> tenantID);
> url = "/_system/config/apimgt/applicationdata/tenant-conf.json";
> data = registry.get(url);
>
> *Error[1]:*
> org.jaggeryjs.scriptengine.exceptions.ScriptException:
> org.mozilla.javascript.WrappedException: Wrapped
> org.wso2.carbon.registry.core.exceptions.ResourceNotFoundException:
> Resource does not exist at path /_system/governance/_system/
> config/apimgt/applicationdata/tenant-conf.json
> (/store/site/blocks/api/api-info/block.jag#53)
>
> I noticed that the "tenant-conf.json" is in the config registry, instead
> of the governance registry.
> Therefore I changed the *.getGovernanceUserRegistry(provider, tenantID)
> to .getConfigSystemRegistry(tenantId) *but then the following error[2]
> occurs
>
> *Error[2]:*
> org.jaggeryjs.scriptengine.exceptions.ScriptException:
> org.mozilla.javascript.EvaluatorException: Can't find method
> org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService.
> getConfigSystemRegistry(org.mozilla.javascript.Undefined).
> (/store/site/blocks/api/api-info/block.jag#41)
>
> Help on this is highly appreciated!
>
> Thanks,
> Viduranga.
>
> On Thu, Dec 7, 2017 at 11:24 AM, Prasanna Dangalla <prasa...@wso2.com>
> wrote:
>
>> HI Viduranga,
>>
>> You can get the content in a registry resource as follows,
>>
>> Object content = resource.getContent();
>> String jsonContent = RegistryUtils.decodeBytes((byte[]) content);
>>
>> This will retourn the You have to get the resource from the tenant
>> registry you need.
>>
>> [1] - https://github.com/wso2/carbon-governance-extensions/blob/ma
>> ster/components/governance-extensions/org.wso2.carbon.govern
>> ance.platform.extensions/src/org/wso2/carbon/governance/
>> platform/extensions/util/Utils.java#L42
>> [2] - https://github.com/wso2/carbon-kernel/blob/4.4.x/core/org.
>> wso2.carbon.registry.core/src/main/java/org/wso2/carbon/regi
>> stry/core/utils/RegistryUtils.java#L1952
>> <https://github.com/wso2/carbon-governance-extensions/blob/master/components/governance-extensions/org.wso2.carbon.governance.platform.extensions/src/org/wso2/carbon/governance/platform/extensions/util/Utils.java#L42>
>>
>> Thanks
>>
>> *Prasanna Dangalla*
>> Senior Software Engineer, WSO2, Inc.; http://wso2.com/
>> lean.enterprise.middleware
>>
>>
>> *cell: +94 718 11 27 51*
>> *twitter: @prasa77*
>>
>> On Thu, Dec 7, 2017 at 11:03 AM, Viduranga Gunarathne <vidura...@wso2.com
>> > wrote:
>>
>>> Hi Irham, Mushthaq
>>>
>>> @Mushthaq, thanks for the prompt reply. I will look into it.
>>>
>>>
>>> On Thu, Dec 7, 2017 at 10:57 AM, Irham Iqbal <iq...@wso2.com> wrote:
>>>
>>>> Hi Viduranga,
>>>>
>>>> What exactly you're trying to do ?
>>>> I mean are you trying to directly read the files from Jaggery or trying
>>>> to access the registry resources by using admin service from Jaggery ?
>>>>
>>>> I need to read the configuration from the registry. This config can be
>>> different from one tenant to another. So the value that should be displayed
>>> in the Store UI should change based on the tenant who has published the API.
>>>
>>>
>>>> Thanks,
>>>> Iqbal
>>>>
>>>> On Thu, Dec 7, 2017 at 10:48 AM, Viduranga Gunarathne <
>>>> vidura...@wso2.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I'm working on APIM 2.1.0 and I need to read a configuration in the
>>>>> tenant registry that is specific to each tenant, from the jaggery layer so
>>>>> that it can be displayed in the Store UI.
>>>>>
>>>>> Any tips on how to do this?
>>>>>
>>>>> Also, The media type of the "tenant-conf" is json and can that be
>>>>> accessed as a json object or is it returned as a resource and we have to
>>>>> convert it to a json object at the jaggery level ?
>>>>>
>>>>> Thanks in advance!
>>>>> Viduranga.
>>>>> --
>>>>> Regards,
>>>>>
>>>>> *Viduranga Gunarathne*
>>>>>
>>>>> *Software Engineer Intern*
>>>>>
>>>>>
>>>>> *WSO2*
>>>>> Email : vidura...@wso2.com
>>>>> Mobile : +94712437484 <+94%2071%20243%207484>
>>>>> Web : http://wso2.com
>>>>> [image: https://wso2.com/signature] <https://wso2.com/signature>
>>>>>
>>>>> _______________________________________________
>>>>> Dev mailing list
>>>>> Dev@wso2.org
>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Irham Iqbal
>>>> Software Engineer
>>>> WSO2
>>>> phone: +94 777888452
>>>> <http://wso2.com/signature>
>>>>
>>>>
>>>
>>>
>>> --
>>> Regards,
>>>
>>> *Viduranga Gunarathne*
>>>
>>> *Software Engineer Intern*
>>>
>>>
>>> *WSO2*
>>> Email : vidura...@wso2.com
>>> Mobile : +94712437484 <+94%2071%20243%207484>
>>> Web : http://wso2.com
>>> [image: https://wso2.com/signature] <https://wso2.com/signature>
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> Dev@wso2.org
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>
>
> --
> Regards,
>
> *Viduranga Gunarathne*
>
> *Software Engineer Intern*
>
>
> *WSO2*
> Email : vidura...@wso2.com
> Mobile : +94712437484 <+94%2071%20243%207484>
> Web : http://wso2.com
> [image: https://wso2.com/signature] <https://wso2.com/signature>
>
> _______________________________________________
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to