You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by Mark Sztainbok <ma...@okta.com> on 2014/09/05 04:05:04 UTC

Some Olingo questions

I've changed over to use Olingo and now I can generate proxies for the AAD Graph API with no issues.

I have a few questions though:

  1.  How do I force the client to use JSON Light (minimalmetadata) with the proxies instead of the OData format?
  2.  Is there a way to not use batch processing when doing a create?
  3.  Is there a way to add a query string parameter to every request? The Graph API (like all Azure API's) requires an API version to be specified as a parameter in the request's query string i.e. https://graph.windows.net/..../users?api-version=<api version> for example. Setting the service root does not work as the query string parameter then becomes part of the main URI for all the OData operations in the middle of the URI (e.g. https://graph.windows.net/f872e367-02c7-4012-a01c-0f5b7c5636ae?api-version=1.21preview/directoryObjects/Microsoft.WindowsAzure.ActiveDirectory.User)

Thanks,
Mark




Re: Some Olingo questions

Posted by Mark Sztainbok <ma...@okta.com>.
Re "Setting the protocol version via a query parameter is not standard, AFAICT.". I previously worked at Microsoft in Windows Azure and the Common Engineering Criteria there make all Azure REST API's use a query string parameter for versioning instead of using a header or as part of the URL. I can't remember the rationale behind it but unfortunately it is the engineering standard there now.

I worked out a way to do it though using a HttpUriRequestFactory with code like this:
    @Override
    public HttpUriRequest create(final HttpMethod method, final URI uri) {
        List<NameValuePair> parameters = URLEncodedUtils.parse(uri, "UTF-8");
        if (!Iterables.any(parameters, new Predicate<NameValuePair>() {
            @Override
            public boolean apply(@Nullable NameValuePair input) {
                return input.getName().equalsIgnoreCase(API_VERSION_PARAM);
            }
        })) {
            parameters = new ArrayList<NameValuePair>(parameters);
            parameters.add(new BasicNameValuePair(API_VERSION_PARAM, this.apiVersion));
        }

        URI newUri;
        try {
            newUri = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath(), URLEncodedUtils.format(parameters, "UTF-8"), uri.getFragment());
        } catch (URISyntaxException e) {
            newUri = uri;
        }

        return super.create(method, newUri);
    }

Is there another better way to it or is this the best way?

From: Francesco Chicchiriccò <il...@apache.org>>
Reply-To: "user@olingo.apache.org<ma...@olingo.apache.org>" <us...@olingo.apache.org>>
Date: Monday, September 8, 2014 at 7:17 AM
To: "user@olingo.apache.org<ma...@olingo.apache.org>" <us...@olingo.apache.org>>
Subject: Re: Some Olingo questions

HI Mark,
see my replies embedded below.

Regards.

On 05/09/2014 04:05, Mark Sztainbok wrote:
I've changed over to use Olingo and now I can generate proxies for the AAD Graph API with no issues.

I have a few questions though:

  1.  How do I force the client to use JSON Light (minimalmetadata) with the proxies instead of the OData format?

The proxy layer requires JSON with full metadata: probably this can be avoided, but not at the moment.


  1.  Is there a way to not use batch processing when doing a create?

Sure: instead of

Service.getV4(serviceRootURL); // (or Service.getV3(...))

use

Service.getV4(serviceRootURL, false); // (or Service.getV3(...))

e.g. ask for non-transactional (= non-batch) service.


  1.  Is there a way to add a query string parameter to every request? The Graph API (like all Azure API's) requires an API version to be specified as a parameter in the request's query string i.e. https://graph.windows.net/..../users?api-version=<api<https://graph.windows.net/%85./users?api-version=%3Capi> version> for example. Setting the service root does not work as the query string parameter then becomes part of the main URI for all the OData operations in the middle of the URI (e.g. https://graph.windows.net/f872e367-02c7-4012-a01c-0f5b7c5636ae?api-version=1.21preview/directoryObjects/Microsoft.WindowsAzure.ActiveDirectory.User)

Setting the protocol version via a query parameter is not standard, AFAICT.
You can either see if this can set via an HTTP header or use an HTTP protocol interceptor for dynamically adding a request parameter to all requests (see [1]).

[1] https://git-wip-us.apache.org/repos/asf?p=olingo-odata4.git;a=blob;f=samples/client/src/main/java/org/apache/olingo/samples/client/core/http/ProtocolInterceptorHttpClientFactory.java

--
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PMC
http://people.apache.org/~ilgrosso/



Re: Some Olingo questions

Posted by Francesco Chicchiriccò <il...@apache.org>.
HI Mark,
see my replies embedded below.

Regards.

On 05/09/2014 04:05, Mark Sztainbok wrote:
> I’ve changed over to use Olingo and now I can generate proxies for the 
> AAD Graph API with no issues.
>
> I have a few questions though:
>
>  1. How do I force the client to use JSON Light (minimalmetadata) with
>     the proxies instead of the OData format?
>

The proxy layer requires JSON with full metadata: probably this can be 
avoided, but not at the moment.

>  1. Is there a way to not use batch processing when doing a create?
>

Sure: instead of

Service.getV4(serviceRootURL); // (or Service.getV3(...))

use

Service.getV4(serviceRootURL, false); // (or Service.getV3(...))

e.g. ask for non-transactional (= non-batch) service.

>  1. Is there a way to add a query string parameter to every request?
>     The Graph API (like all Azure API’s) requires an API version to be
>     specified as a parameter in the request’s query string i.e.
>     https://graph.windows.net/…./users?api-version=<api
>     <https://graph.windows.net/%85./users?api-version=%3Capi> version>
>     for example. Setting the service root does not work as the query
>     string parameter then becomes part of the main URI for all the
>     OData operations in the middle of the URI (e.g.
>     https://graph.windows.net/f872e367-02c7-4012-a01c-0f5b7c5636ae?api-version=1.21preview/directoryObjects/Microsoft.WindowsAzure.ActiveDirectory.User)
>

Setting the protocol version via a query parameter is not standard, AFAICT.
You can either see if this can set via an HTTP header or use an HTTP 
protocol interceptor for dynamically adding a request parameter to all 
requests (see [1]).

[1] 
https://git-wip-us.apache.org/repos/asf?p=olingo-odata4.git;a=blob;f=samples/client/src/main/java/org/apache/olingo/samples/client/core/http/ProtocolInterceptorHttpClientFactory.java

-- 
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PMC
http://people.apache.org/~ilgrosso/