Hi Ishara,

Since this is direct Java reflection call, ideally it shouldn't return null
if there is a @Path annotation.
That seems strange.

Thanks
Thusitha

On Mon, Jun 5, 2017 at 4:58 AM, Ishara Cooray <[email protected]> wrote:

> You can access the actual method that will get invoke at the Interceptor
> level
> e.g. request.getProperty("method");[1] So then you can get the @Path
> value of the method and compare that with the request.getUri().
>
> Hi Thusitha,
>
> This worked for me.
> However, for resource paths such as "*/apis*" @Path returns null where as
> "*/apis/{apiId}*" returns the correct value.
>
> It seems very first collection returns null for @Path annotation.
> Is it an expected behavior?
>
>
> ​
>
> Thanks & Regards,
> Ishara Cooray
> Senior Software Engineer
> Mobile : +9477 262 9512 <+94%2077%20262%209512>
> WSO2, Inc. | http://wso2.com/
> Lean . Enterprise . Middleware
>
> On Mon, May 29, 2017 at 10:06 PM, Thusitha Thilina Dayaratne <
> [email protected]> wrote:
>
>> Hi Ishara,
>>
>> You can access the actual method that will get invoke at the Interceptor
>> level
>> e.g. request.getProperty("method");[1] So then you can get the @Path
>> value of the method and compare that with the request.getUri().
>>
>> [1] - https://github.com/wso2/msf4j/blob/v2.3.0-m2/core/src/main
>> /java/org/wso2/msf4j/internal/router/HttpMethodInfo.java#L174
>>
>> Thanks
>> Thusitha
>>
>> On Mon, May 29, 2017 at 1:51 AM, Ishara Cooray <[email protected]> wrote:
>>
>>> Ths usecase behind this is,
>>>
>>> we have scopes defined in apim product REST APIs for each resource path
>>> as below.
>>>
>>> /apis/{apiId}:
>>>
>>> #-----------------------------------------------------
>>>
>>> # Retrieve the details of an API definition
>>>
>>> #-----------------------------------------------------
>>>
>>>   get:
>>>
>>>     x-scope: apim:api_view
>>>
>>>     x-wso2-curl: "curl -k -H \"Authorization: Bearer
>>> ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://127.0.0.1:9443/api/am/
>>> publisher/v1.0/apis/7a2298c4-c905-403f-8fac-38c73301631f"
>>>
>>> ......
>>>
>>>
>>> We are keeping track of these resource to scope mapping and at the time
>>> of a new request, we need to validate the scope.
>>>
>>> But, the request coming with a value(206e1b0b-a48e-47c9-95d0-3eb85544cf2e)
>>> for the variable(apiId), hence unable to find the resource template to
>>> match unless we do a string manipulation(we are maintaining a map for the
>>> resource to scope mapping).
>>>
>>>
>>> We better avoid string manipulations as much as possible because this
>>> will take place in gateway.
>>>
>>>
>>> Therefore need to check the possibility of supporting this from MSF4J
>>> level so that we can get template info from the Request object itself.
>>>
>>>
>>>
>>>
>>> Thanks & Regards,
>>> Ishara Cooray
>>> Senior Software Engineer
>>> Mobile : +9477 262 9512 <+94%2077%20262%209512>
>>> WSO2, Inc. | http://wso2.com/
>>> Lean . Enterprise . Middleware
>>>
>>> On Mon, May 29, 2017 at 12:40 PM, Ishara Cooray <[email protected]>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> We have a requirement to identify the request template for a given http
>>>> request.
>>>>
>>>> For example,
>>>> *Req: *
>>>> /api/am/publisher/v1.0/apis/206e1b0b-a48e-47c9-95d0-3eb85544cf2e
>>>>
>>>> *Req path:*
>>>> /apis/206e1b0b-a48e-47c9-95d0-3eb85544cf2e
>>>>
>>>> *Need *to identify corresponding *template as *
>>>> apis/{apiId}
>>>>
>>>> Is there a way to get this info from the MSF4J level?
>>>>
>>>>
>>>> Thanks & Regards,
>>>> Ishara Cooray
>>>> Senior Software Engineer
>>>> Mobile : +9477 262 9512 <+94%2077%20262%209512>
>>>> WSO2, Inc. | http://wso2.com/
>>>> Lean . Enterprise . Middleware
>>>>
>>>
>>>
>>
>>
>> --
>> Thusitha Dayaratne
>> WSO2 Inc. - lean . enterprise . middleware |  wso2.com
>>
>> Mobile  +94712756809 <+94%2071%20275%206809>
>> Blog      alokayasoya.blogspot.com
>> About    http://about.me/thusithathilina
>> <http://wso2.com/signature>
>>
>>
>


-- 
Thusitha Dayaratne
WSO2 Inc. - lean . enterprise . middleware |  wso2.com

Mobile  +94712756809
Blog      alokayasoya.blogspot.com
About    http://about.me/thusithathilina
<http://wso2.com/signature>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to