Hi Gayan,

On 22 April 2014 09:04, Gayan Gunawardana <[email protected]> wrote:

> Hi,
>
> I am working on altering  "org.wso2.carbon.apimgt.interceptor" component
> to support generic API formats. In the available version it supports only
> one context noun before version therefore we cannot define APIs like
> foo/bar/1.0.0
>
> What I am doing is make it generic to support any sub context after root
> context like a/b/c/d/1.0.0
>
> The logic is to compare existing AM_API table records against current
> request including version and pick up context, version from database
> record. The logic works fine and I had to modify
>  interceptorOps.doThrottle(request, accessToken) -->
> interceptorOps.doThrottle(request, accessToken, context, apiVersion); to
> pass context and version
> now altered doThrottle method like
>
> public boolean doThrottle(Request request, String accessToken, String
> context, String version) throws APIFaultException {
>
>         String apiName = context;
>         String apiVersion = version;
>         String apiIdentifier = apiName + "-" + apiVersion;
>
>         APIThrottleHandler throttleHandler = null;
>         ConfigurationContext cc = DataHolder.getServerConfigContext();
>
>          if (cc.getProperty(apiIdentifier) == null) {
>                 throttleHandler = new APIThrottleHandler();
>                     /* Add the Throttle handler to ConfigContext against
> API Identifier */
>                  cc.setProperty(apiIdentifier, throttleHandler);
>          } else {
>                 throttleHandler = (APIThrottleHandler)
> cc.getProperty(apiIdentifier);
>          }
>
>           if (throttleHandler.doThrottle(request, apiKeyValidationDTO,
> accessToken)) {
>                 return true;
>           } else {
>                 throw new
> APIFaultException(APIManagerErrorConstants.API_THROTTLE_OUT,
>                                                 "You have exceeded your
> quota");
>            }
>
>     }
>
> What happen here is ConfigurationContext getting null and throws null
> pointer exception. This can be avoided by doing simple null check but will
> there be any side effects by doing it ?
>
> If configuration context is null how can I invoke setProperty ?
>

As found while debugging, interceptor component activation doesn't complete
successfully due to some unsatisfied dependencies with the usage.publisher
component. As a result ConfigurationContext become null. We need to further
debug and find the root cause of this issue. I'll also have a look.

Thanks,
Lakmali

>
> --
> Gayan Gunawardana
> Software Engineer; WSO2 Inc.; http://wso2.com/
> Email: [email protected]
> Mobile: +94 (71) 8020933
>



-- 
Lakmali Baminiwatta
 Software Engineer
WSO2, Inc.: http://wso2.com
lean.enterprise.middleware
mobile:  +94 71 2335936
blog : lakmali.com
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to