RoyZeng / odata4j

Automatically exported from code.google.com/p/odata4j
0 stars 0 forks source link

Add ability to specify custom url parameter (with fix) #279

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Some OData producers require custom url parameters to be given.  A common 
example is to supply an "API Key" to authorize the request.

I have implemented this new feature as an OClientBehavior.  The attached class 
addresses this feature.  I hope you will consider it for a future release.

Example usage:

Builder builder = ODataConsumers.newBuilder(endpointUri);

        List<OClientBehavior> behaviors = new ArrayList<OClientBehavior>();

        /*
         * Add a custom URL parameter to specify the Intel API Key
         */
        behaviors.add(new CustomParametersBehavior("api_key", IntelApiKey));

        if (format != null) {
            builder = builder.setFormatType(format);
        }

        if (methodToTunnel != null) {
            behaviors.add(new MethodTunnelingBehavior(methodToTunnel));
        }

        if (behaviors.size() > 0)
            builder = builder.setClientBehaviors(behaviors.toArray(new OClientBehavior[]{}));

Original issue reported on code.google.com by mcoo...@magnicomp.com on 31 Mar 2014 at 8:15

Attachments: