Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

Commit

Permalink
Move new client to a simpler package
Browse files Browse the repository at this point in the history
  • Loading branch information
berezovskyi committed Nov 9, 2020
1 parent 9f4a012 commit 47af0d6
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* Samuel Padgett - handle any redirect status code
* Jad El-khoury - Migrate client from Wink to implementation-independent JAX-RS 2.0
*******************************************************************************/
package org.eclipse.lyo.oslc4j.client;
package org.eclipse.lyo.client;

import java.util.Map;
import javax.ws.rs.client.Client;
Expand Down Expand Up @@ -77,7 +77,7 @@ public interface IOslcClient {
public Response getResource (String url, Map<String, String> requestHeaders, String mediaType, String configurationContext);

public Response getResource (String url, Map<String, String> requestHeaders, String mediaType, boolean handleRedirects);

public Response getResource (String url, Map<String, String> requestHeaders, String mediaType, String configurationContext, boolean handleRedirects);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* http://www.eclipse.org/org/documents/edl-v10.php.
*/

package org.eclipse.lyo.oslc4j.client;
package org.eclipse.lyo.client;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -31,8 +31,6 @@
import javax.ws.rs.core.Response;

import org.apache.http.HttpStatus;
import org.apache.http.client.ClientProtocolException;
import org.eclipse.lyo.oslc4j.core.annotation.OslcSchema;

/**
* A filter that can be registered in order to non-preemptively handle JEE Form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Samuel Padgett - deprecate constants for non-existent terms
*******************************************************************************/

package org.eclipse.lyo.oslc4j.client;
package org.eclipse.lyo.client;

/**
* General OSLC constants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* Samuel Padgett - handle any redirect status code
* Jad El-khoury - Migrate client from Wink to implementation-independent JAX-RS 2.0
*******************************************************************************/
package org.eclipse.lyo.oslc4j.client;
package org.eclipse.lyo.client;

import java.io.IOException;
import java.net.URI;
Expand All @@ -31,7 +31,6 @@
import java.util.Map;

import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.eclipse.lyo.oslc4j.client;
package org.eclipse.lyo.client;

import javax.ws.rs.client.ClientBuilder;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.eclipse.lyo.oslc4j.client;
package org.eclipse.lyo.client;

public class OslcClientFactory {

static public OslcOAuthClientBuilder oslcOAuthClientBuilder() {
return new OslcOAuthClientBuilder();
}

static public OslcClientBuilder oslcClientBuilder() {
return new OslcClientBuilder();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Samuel Padgett - don't re-register JAX-RS applications for every request
* Samuel Padgett - add two-legged OAuth support
*******************************************************************************/
package org.eclipse.lyo.oslc4j.client;
package org.eclipse.lyo.client;

import java.io.IOException;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -65,7 +65,7 @@ public OslcOAuthClient(
UnderlyingHttpClient underlyingHttpClient) {

oauthAccessor = accessor;

oauthRealmName = "Jazz";
// Change if a different name was detected
if (!StringUtils.isEmpty(realm)) {
Expand All @@ -84,7 +84,7 @@ public OslcOAuthClient(
public OslcClient getOslcClient() {
return oslcClient;
}

private Map<String, String> appendAuthorizationHeader(String url, String httpMethod, Map<String, String> requestHeaders) throws IOException, OAuthException, URISyntaxException {
if (requestHeaders == null) {
requestHeaders = new HashMap<>();
Expand Down Expand Up @@ -123,7 +123,7 @@ private boolean performedOAuthNegotiation() {
public Optional<String> performOAuthNegotiation(String callbackURL) throws IOException, OAuthException, URISyntaxException {
return performOAuthNegotiationInternal(false, callbackURL);
}

private Optional<String> performOAuthNegotiationInternal(boolean restart, String callbackURL) throws IOException, OAuthException, URISyntaxException {
//No request token yet, get the request token and throw exception to redirect for authorization.
if (oauthAccessor.requestToken == null) {
Expand All @@ -134,10 +134,10 @@ public HttpClient getHttpClient(URL url) {
});
OAuthMessage message = client.getRequestTokenResponse(oauthAccessor, OAuthMessage.GET, null);

String userAuthorizationURL = oauthAccessor.consumer.serviceProvider.userAuthorizationURL +
String userAuthorizationURL = oauthAccessor.consumer.serviceProvider.userAuthorizationURL +
"?oauth_token=" + oauthAccessor.requestToken +
"&oauth_callback="+URLEncoder.encode(callbackURL, "UTF-8");

return Optional.of(userAuthorizationURL);
}

Expand Down Expand Up @@ -195,7 +195,7 @@ public Response getResource(String url, Map<String, String> requestHeaders, Stri
public Response getResource(String url, Map<String, String> requestHeaders, String mediaType, String configurationContext) {
return this.getResource(url, requestHeaders, mediaType,configurationContext, true);
}

@Override
public Response getResource(String url, Map<String, String> requestHeaders, String mediaType, boolean handleRedirects) {
return this.getResource(url, requestHeaders, mediaType, null, handleRedirects);
Expand All @@ -211,7 +211,7 @@ public Response getResource(String url, Map<String, String> requestHeaders, Stri
}
return oslcClient.getResource(url, headers, mediaType,configurationContext, handleRedirects);
}

@Override
public Response deleteResource(String url) {
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.eclipse.lyo.oslc4j.client;
package org.eclipse.lyo.client;

import javax.ws.rs.client.ClientBuilder;

Expand All @@ -19,7 +19,7 @@ public class OslcOAuthClientBuilder {
private String consumerSecret;

private String oauthRealmName;

private ClientBuilder clientBuilder;
private UnderlyingHttpClient underlyingHttpClient;

Expand All @@ -45,9 +45,9 @@ public OslcOAuthClientBuilder setFromRootService(RootServicesHelper rootService)
}

public OslcOAuthClientBuilder setOAuthServiceProvider(String requestTokenURL, String authorizationTokenURL, String accessTokenURL) {
this.requestTokenURL = requestTokenURL;
this.requestTokenURL = requestTokenURL;
this.authorizationTokenURL = authorizationTokenURL;
this.accessTokenURL = accessTokenURL;
this.accessTokenURL = accessTokenURL;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Michael Fiedler - initial API and implementation
*******************************************************************************/

package org.eclipse.lyo.oslc4j.client;
package org.eclipse.lyo.client;

/**
* Constants for Jazz rootservices entries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
* Samuel Padgett - add request consumer key and OAuth approval module URLs
* Samuel Padgett - handle trailing '/' in baseUrl
*******************************************************************************/
package org.eclipse.lyo.oslc4j.client;
package org.eclipse.lyo.client;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.eclipse.lyo.oslc4j.client;
package org.eclipse.lyo.client;

import javax.ws.rs.client.Client;
import org.apache.http.client.HttpClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
* http://www.eclipse.org/org/documents/edl-v10.php.
*/

package org.eclipse.lyo.oslc4j.client.resources;
package org.eclipse.lyo.client.resources;


import javax.ws.rs.core.Response;

import org.eclipse.lyo.oslc4j.client.OSLCConstants;
import org.eclipse.lyo.oslc4j.client.OslcClient;
import org.eclipse.lyo.client.OslcClient;
import org.eclipse.lyo.client.OSLCConstants;

import javax.ws.rs.client.WebTarget;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* Michael Fiedler - initial API and implementation
*******************************************************************************/
package org.eclipse.lyo.oslc4j.client.resources;
package org.eclipse.lyo.client.resources;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Samuel Padgett - support setting member property
* Samuel Padgett - preserve member property on call to getNext()
*******************************************************************************/
package org.eclipse.lyo.oslc4j.client.resources;
package org.eclipse.lyo.client.resources;

import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
Expand All @@ -28,7 +28,7 @@

import javax.ws.rs.core.Response;

import org.eclipse.lyo.oslc4j.client.OSLCConstants;
import org.eclipse.lyo.client.OSLCConstants;
import org.eclipse.lyo.oslc4j.core.exception.OslcCoreApplicationException;
import org.eclipse.lyo.oslc4j.core.model.OslcConstants;
import org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* Gabriel Ruelas - initial API and implementation
* Carlos A Arreola - initial API and implementation
*******************************************************************************/
package org.eclipse.lyo.oslc4j.client.resources;
package org.eclipse.lyo.client.resources;

import net.oauth.OAuthException;
import org.eclipse.lyo.client.OslcClient;
import org.eclipse.lyo.client.exception.ResourceNotFoundException;
import org.eclipse.lyo.oslc4j.client.OSLCConstants;
import org.eclipse.lyo.oslc4j.client.OslcClient;
import org.eclipse.lyo.client.OSLCConstants;
import org.eclipse.lyo.oslc4j.core.model.CreationFactory;
import org.eclipse.lyo.oslc4j.core.model.ResourceShape;
import org.eclipse.lyo.oslc4j.core.model.Service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,11 @@
* Samuel Padgett - initial API and implementation
* Samuel Padgett - set timeout on postInvalidOslcResource()
*******************************************************************************/
package org.eclipse.lyo.oslc4j.client.test;

import java.io.IOException;
import java.net.URISyntaxException;
package org.eclipse.lyo.client.test;

import javax.ws.rs.core.Response;
import javax.xml.namespace.QName;

import javax.ws.rs.ClientErrorException;

import org.eclipse.lyo.oslc4j.client.OSLCConstants;
import org.eclipse.lyo.oslc4j.client.OslcClient;
import org.junit.Ignore;
import org.eclipse.lyo.client.OslcClient;
import org.junit.Test;
import static org.assertj.core.api.Assertions.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@
* Samuel Padgett - test member property on call to OslcQueryResult.getNext()
* Samuel Padgett - remove previous test as it causes problems in our Hudson builds
*******************************************************************************/
package org.eclipse.lyo.oslc4j.client.test;
package org.eclipse.lyo.client.test;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;

import java.io.InputStream;
import java.net.MalformedURLException;


import javax.ws.rs.core.Response;

import org.eclipse.lyo.oslc4j.client.OslcClient;
import org.eclipse.lyo.oslc4j.client.resources.OslcQuery;
import org.eclipse.lyo.oslc4j.client.resources.OslcQueryParameters;
import org.eclipse.lyo.oslc4j.client.resources.OslcQueryResult;
import org.eclipse.lyo.client.OslcClient;
import org.eclipse.lyo.client.resources.OslcQuery;
import org.eclipse.lyo.client.resources.OslcQueryParameters;
import org.eclipse.lyo.client.resources.OslcQueryResult;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
Expand Down

0 comments on commit 47af0d6

Please sign in to comment.