Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [lyo-dev] Jersey and Wink support in Lyo

But we are talking about a JAX-RS client API, correct?

As far as I understand, that API does not offer control over the redirection policy: https://stackoverflow.com/questions/21778393/jersey-jax-rs-client-2-5-follow-redirect#25301746

--
/Andrew



On Sun, Nov 4, 2018 at 10:27 AM +0100, "Jad El-Khoury" <jad@xxxxxx> wrote:

Jim

 

We can of course complement with new oslcClient constructors. At the moment, I am stuck is in the basics of the current constructor below.

In short, how to create an OSLCClient with Apache Http Client, with the necessary redirect & SSL support.

I can create with default Apache client. But not sure (nor can I test) the specific of the code below.

 

       /**

       * Initialize a new OslcClient using an Apache Http Components 4 Http client and configuration.

       * Use the provided TrustManagers and X509HostnameVerifiers instead of the defaults which do no verification;

       */

       public OslcClient(TrustManager [] trustManagers, X509HostnameVerifier hostnameVerifier)

       {

              httpClient = new DefaultHttpClient(new ThreadSafeClientConnManager());

              httpClient.setRedirectStrategy(new RedirectStrategy() {

                     @Override

                     public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response, HttpContext context)  {

                           return null;

                     }

 

                     @Override

                     public boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context) {

ureturn false;

                     }

              });

              this.trustManagers = trustManagers;

              this.hostnameVerifier = hostnameVerifier;

              setupSSLSupport();

              clientPool = new OAuthHttpPool();

              clientConfig = new ApacheHttpClientConfig(httpClient);

              …

       }

 

______________________________

Jad El-khoury, PhD

KTH Royal Institute of Technology

School of Industrial Engineering and Management, Mechatronics Division

Brinellvägen 83, SE-100 44 Stockholm, Sweden

Phone: +46(0)8 790 6877 Mobile: +46(0)70 773 93 45

jad@xxxxxx, www.kth.se

 

From: lyo-dev-bounces@xxxxxxxxxxx [mailto:lyo-dev-bounces@xxxxxxxxxxx] On Behalf Of Jim Amsden
Sent: 02 November 2018 18:34
To: Lyo project developer discussions <lyo-dev@xxxxxxxxxxx>
Subject: Re: [lyo-dev] Jersey and Wink support in Lyo

 

Here's what I did:


                        client = new OslcClient();
                        // Add a receptor to set the Authorization header as a default header for all requests
                        // This is using deprecated code because OSLC4J OslcClient needs to be updated at some point
                        Header header = new BasicHeader(HttpHeaders.AUTHORIZATION,  "Basic "+Base64.encode((userId+":"+password).getBytes()));
                        List<Header> headers = new ArrayList<Header>();
                        headers.add(header);
                        RequestDefaultHeaders defaultHeaders = new RequestDefaultHeaders(headers);
                        ((DefaultHttpClient)client.getHttpClient()).addRequestInterceptor(defaultHeaders);

                        String catalogUrl = serverUrl + "/services/catalog/singleton";
                       
                        String orgTitle = "IoT Platform Service Provider: "+orgId+"(/"+orgId+")";
                        String serviceProviderUrl = client.lookupServiceProviderUrl(catalogUrl, orgTitle);

                        queryCapability = client.lookupQueryCapability(serviceProviderUrl,
                                        Oslc_iotDomainConstants.IOT_PLATFORM_NAMSPACE, Oslc_iotDomainConstants.DEVICETYPE_TYPE);

                        creationFactory = client.lookupCreationFactory(serviceProviderUrl,
                                        Oslc_iotDomainConstants.IOT_PLATFORM_NAMSPACE, Oslc_iotDomainConstants.DEVICETYPE_TYPE);

I needed to do this to handle login. Maybe we need an OslcClient(userid, password) constructor. I used the above as a work around.

This is using old, deprecated HttpClient code.


Jim Amsden, Senior Technical Staff Member
OSLC and Linked Lifecycle Data
919-525-6575




From:        Jad El-Khoury <jad@xxxxxx>
To:        Lyo project developer discussions <lyo-dev@xxxxxxxxxxx>
Date:        11/02/2018 11:23 AM
Subject:        Re: [lyo-dev] Jersey and Wink support in Lyo
Sent by:        lyo-dev-bounces@xxxxxxxxxxx





I see.

What we really need help with is to work out how to configure oslcClient with ApacheClient. The constructor for OslcClient.

I have the feeling this (very old deprecated) part of the code is for jazz-related needs.

Anyone on this mailing list that can help out?

/Jad  

On 2 Nov 2018, at 15:21, Nicholas Crossley <nick_crossley@xxxxxxxxxx> wrote:

I'd like to, but I'm currently assigned to other work, and not sure if/when I'll be able to get back to more active involvement with OSLC & Lyo.

Nick.




From:        
Jad El-Khoury <jad@xxxxxx>
To:        
Lyo project developer discussions <
lyo-dev@xxxxxxxxxxx>
Date:        
10/20/2018 01:58 AM
Subject:        
Re: [lyo-dev] Jersey and Wink support in Lyo
Sent by:        
lyo-dev-bounces@xxxxxxxxxxx





Let’s aim for a Jersey/wink-free SDK then.

I will need to prioritize the Core part, which client depends on anyway.
Nick! Would you be able to help out with Client eventually ?

Jad



On 19 Oct 2018, at 18:43, Nicholas Crossley <nick_crossley@xxxxxxxxxx> wrote:

As prominently a client developer, I'd love Lyo to get to the stage where the client library dependencies were much smaller and simpler - today with Wink et al they are huge. In other words, my personal preference would be just the same as Andrews:

"
Andrew hat: migrate everything to raw JAX-RS 2.0 and make sure no Jersey-specific stuff is introduced."

Nick.




From:        
Andrii Berezovskyi <andriib@xxxxxx>
To:        
Lyo project developer discussions <
lyo-dev@xxxxxxxxxxx>
Date:        
10/19/2018 08:39 AM
Subject:        
Re: [lyo-dev] Jersey and Wink support in Lyo
Sent by:        
lyo-dev-bounces@xxxxxxxxxxx





Well, we can create new packages for the JAX-RS 2.0 migration and deprecate the 1.1 packages and mark them for removal in Lyo 3.0. This way the client & legacy apps can still depend on Wink while the generator can migrate over to use the JAX-RS 2.0 compliant deps.

/A


Den 2018-10-19  16:01 skrev "Jad El-Khoury" <jad@xxxxxx> följande:

Hi

I wanted to suggested we can wait with migrating oslc.client. This would mean that one can run oslc servers with jersey 2.0, and oslc clients with wink 1.0. (but not together I guess)
But that is not an option, since oslc.client has a dependency on oslc.core


Assuming I can go ahead to put some more effort for this migration, let’s start a branch to experiment and find out what the best options are.

Andrii! I am trying to decipher your notes! So once I have something going, I can share a working example to get going with.

regards
______________________________
Jad El-khoury, PhD
KTH Royal Institute of Technology
School of Industrial Engineering and Management, Mechatronics Division
Brinellvägen 83, SE-100 44 Stockholm, Sweden
Phone: +46(0)8 790 6877 Mobile: +46(0)70 773 93 45

jad@xxxxxx, https://www.kth.se/profile/jad

From:
Andrii Berezovskyi
Sent:
Friday, 19 October 2018 15:32
To:
Jim Amsden <
jamsden@xxxxxxxxxx>
Cc:
Jad El-Khoury <
jad@xxxxxx>; Lyo project developer discussions <lyo-dev@xxxxxxxxxxx>; 'Khatri Yash' <yash.khatri@xxxxxxxxxx>
Subject:
Re: Jersey and Wink support in Lyo


Jim,

Glad we are thinking alike.

 

  1. Yes, the REST API shall not change in any way.
  1. Strictly speaking, JAX-RS 1.1 did not have a client spec. Wink Client is our biggest liability ATM.
  1. There were problems with resource shapes on the server side. I did not get the client to work at all.

 
I shared the notes with Jad & Yash, they were pretty messy. Maybe they can repost them in lyo-dev if they get a chance to follow them?

/A


Den 2018-10-19  15:14 skrev "Jim Amsden" <jamsden@xxxxxxxxxx> följande:

Andrew,
I like how you're thinking on this. A few questions:

1. For servers, will switching to JAX-RS 2.0 have any impact at the REST API that would impact existing HTTP client applications? That is, would only the server implementation change, and not the actual HTTP REST API?

2. For existing JAX-RS 1.0 clients: will they still work with any Lyo OSLC server, regardless of Wink or Jersey implementation?

3. If there are incompatibilities, what are they? I'm hoping the client and server APIs could be migrated or at least used independently.





Jim Amsden, Senior Technical Staff Member

OSLC and Linked Lifecycle Data

919-525-6575





From:        
Andrii Berezovskyi <andriib@xxxxxx>
To:        
Lyo project developer discussions <
lyo-dev@xxxxxxxxxxx>
Cc:        
Jad El-Khoury <
jad@xxxxxx>, Jim Amsden <jamsden@xxxxxxxxxx>, 'Khatri Yash' <yash.khatri@xxxxxxxxxx>
Date:        
10/19/2018 07:24 AM
Subject:        
Re: Jersey and Wink support in Lyo








Jad,

Let me give two answers. Andrew hat: migrate everything to raw JAX-RS 2.0 and make sure no Jersey-specific stuff is introduced. Allow Lyo Core to be used with any JAX-RS framework. Make Lyo Designer emit Jersey based adaptors. Ask Ricardo Javier, for example, to test Lyo Core with RESTEasy/Wildfly/Thorntail.

Lyo project lead hat: do whatever users of Lyo would prefer, but given that I managed to run a Lyo adaptor Jersey pretty easily once (partially), it should be straightforward to move directly to JAX-RS 2.0. If you want to play it safe, we can migrate to the old Jersey (1.19) that supports JAX-RS 1.1. Also, migrate Lyo Client later.

/A


Den 2018-10-19  11:44 skrev "Jad El-Khoury" <
jad@xxxxxx> följande:

Hej

What’s your take on supporting Jersey (JAX-RS 2.0) in Lyo?
I see 2 alternatives:

  1. We keep Wink (JAX-RS 1.0) as well as Jersey (More complicated, but we keep Lyo compatible for old users)
  1. We migrate from Wink to Jersey.  (Less code for us to maintain, but will force users to also migrate to Jersey).

 
regards
______________________________
Jad El-khoury, PhD
KTH Royal Institute of Technology
School of Industrial Engineering and Management, Mechatronics Division
Brinellvägen 83, SE-100 44 Stockholm, Sweden
Phone: +46(0)8 790 6877 Mobile: +46(0)70 773 93 45

jad@xxxxxx, https://www.kth.se/profile/jad



_______________________________________________
lyo-dev mailing list

lyo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

https://dev.eclipse.org/mailman/listinfo/lyo-dev


_______________________________________________
lyo-dev mailing list
lyo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/lyo-dev_______________________________________________
lyo-dev mailing list
lyo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

https://dev.eclipse.org/mailman/listinfo/lyo-dev


_______________________________________________
lyo-dev mailing list
lyo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/lyo-dev_______________________________________________
lyo-dev mailing list
lyo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/lyo-dev


Back to the top