Package org.eclipse.lyo.client
Class OslcOAuthClient
- java.lang.Object
-
- org.eclipse.lyo.client.OslcOAuthClient
-
- All Implemented Interfaces:
IOslcClient
public class OslcOAuthClient extends Object implements IOslcClient
-
-
Constructor Summary
Constructors Constructor Description OslcOAuthClient(net.oauth.OAuthAccessor accessor, String realm, javax.ws.rs.client.ClientBuilder clientBuilder, UnderlyingHttpClient underlyingHttpClient)Initialize an OAuthClient with the required OAuth URLs
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.ws.rs.core.ResponsecreateResource(String url, Object artifact, String mediaType)Create (POST) an artifact to a URL - usually an OSLC Creation Factoryjavax.ws.rs.core.ResponsecreateResource(String url, Object artifact, String mediaType, String acceptType)Create (POST) an artifact to a URL - usually an OSLC Creation Factoryjavax.ws.rs.core.ResponsecreateResource(String url, Object artifact, String mediaType, String acceptType, String configurationContext)javax.ws.rs.core.ResponsedeleteResource(String url)Delete an OSLC resource and return a Wink ClientResponsejavax.ws.rs.core.ResponsedeleteResource(String url, String configurationContext)javax.ws.rs.client.ClientgetClient()Returns the JAX-RS client for this OslcClient.OslcClientgetOslcClient()javax.ws.rs.core.ResponsegetResource(String url)Gets an OSLC resource usingapplication/rdf+xml.javax.ws.rs.core.ResponsegetResource(String url, String mediaType)Gets an OSLC resource.javax.ws.rs.core.ResponsegetResource(String url, Map<String,String> requestHeaders)Gets an OSLC resource.javax.ws.rs.core.ResponsegetResource(String url, Map<String,String> requestHeaders, String mediaType)javax.ws.rs.core.ResponsegetResource(String url, Map<String,String> requestHeaders, String mediaType, boolean handleRedirects)javax.ws.rs.core.ResponsegetResource(String url, Map<String,String> requestHeaders, String mediaType, String configurationContext)javax.ws.rs.core.ResponsegetResource(String url, Map<String,String> requestHeaders, String mediaType, String configurationContext, boolean handleRedirects)Optional<String>performOAuthNegotiation(String callbackURL)Performs necessary OAuth negotiation.javax.ws.rs.core.ResponseupdateResource(String url, Object artifact, String mediaType)Update (PUT) an artifact to a URL - usually the URL for an existing OSLC artifactjavax.ws.rs.core.ResponseupdateResource(String url, Object artifact, String mediaType, String acceptType)Update (PUT) an artifact to a URL - usually the URL for an existing OSLC artifactjavax.ws.rs.core.ResponseupdateResource(String url, Object artifact, String mediaType, String acceptType, String ifMatch)Update (PUT) an artifact to a URL - usually the URL for an existing OSLC artifactjavax.ws.rs.core.ResponseupdateResource(String url, Object artifact, String mediaType, String acceptType, String ifMatch, String configurationContext)
-
-
-
Constructor Detail
-
OslcOAuthClient
public OslcOAuthClient(net.oauth.OAuthAccessor accessor, String realm, javax.ws.rs.client.ClientBuilder clientBuilder, UnderlyingHttpClient underlyingHttpClient)Initialize an OAuthClient with the required OAuth URLs- Parameters:
requestTokenURL-authorizationTokenURL-accessTokenURL-consumerKey-consumerSecret-
-
-
Method Detail
-
getOslcClient
public OslcClient getOslcClient()
-
performOAuthNegotiation
public Optional<String> performOAuthNegotiation(String callbackURL) throws IOException, net.oauth.OAuthException, URISyntaxException
Performs necessary OAuth negotiation. - get request token - throw redirect exception to authorization URL (and print message) - exchange request token for access token - access protected URL and return OAuthMessage- Parameters:
callbackURL-- Returns:
- Throws:
IOExceptionnet.oauth.OAuthExceptionURISyntaxException
-
getClient
public javax.ws.rs.client.Client getClient()
Description copied from interface:IOslcClientReturns the JAX-RS client for this OslcClient. Do not touch unless needed.- Specified by:
getClientin interfaceIOslcClient- Returns:
- the JAX-RS client
-
getResource
public javax.ws.rs.core.Response getResource(String url)
Description copied from interface:IOslcClientGets an OSLC resource usingapplication/rdf+xml. UseIOslcClient.getResource(String, String)to specify the media type orIOslcClient.getResource(String, Map)to add other request headers.- Specified by:
getResourcein interfaceIOslcClient
-
getResource
public javax.ws.rs.core.Response getResource(String url, String mediaType)
Description copied from interface:IOslcClientGets an OSLC resource. UseIOslcClient.getResource(String, Map)instead to add other request headers.- Specified by:
getResourcein interfaceIOslcClient- Parameters:
url- the resource URLmediaType- the requested media type to use in the HTTP Accept request header
-
getResource
public javax.ws.rs.core.Response getResource(String url, Map<String,String> requestHeaders)
Description copied from interface:IOslcClientGets an OSLC resource.- Specified by:
getResourcein interfaceIOslcClient- Parameters:
url- the resource URLrequestHeaders- the HTTP request headers to use. If theAcceptheader is not in the map, it defaults toapplication/rdf+xml. IfOSLC-Core-Versionis not in the map, it defaults to2.0.
-
getResource
public javax.ws.rs.core.Response getResource(String url, Map<String,String> requestHeaders, String mediaType)
- Specified by:
getResourcein interfaceIOslcClient
-
getResource
public javax.ws.rs.core.Response getResource(String url, Map<String,String> requestHeaders, String mediaType, String configurationContext)
- Specified by:
getResourcein interfaceIOslcClient
-
getResource
public javax.ws.rs.core.Response getResource(String url, Map<String,String> requestHeaders, String mediaType, boolean handleRedirects)
- Specified by:
getResourcein interfaceIOslcClient
-
getResource
public javax.ws.rs.core.Response getResource(String url, Map<String,String> requestHeaders, String mediaType, String configurationContext, boolean handleRedirects)
- Specified by:
getResourcein interfaceIOslcClient
-
deleteResource
public javax.ws.rs.core.Response deleteResource(String url)
Description copied from interface:IOslcClientDelete an OSLC resource and return a Wink ClientResponse- Specified by:
deleteResourcein interfaceIOslcClient
-
deleteResource
public javax.ws.rs.core.Response deleteResource(String url, String configurationContext)
- Specified by:
deleteResourcein interfaceIOslcClient
-
createResource
public javax.ws.rs.core.Response createResource(String url, Object artifact, String mediaType)
Description copied from interface:IOslcClientCreate (POST) an artifact to a URL - usually an OSLC Creation Factory- Specified by:
createResourcein interfaceIOslcClient
-
createResource
public javax.ws.rs.core.Response createResource(String url, Object artifact, String mediaType, String acceptType)
Description copied from interface:IOslcClientCreate (POST) an artifact to a URL - usually an OSLC Creation Factory- Specified by:
createResourcein interfaceIOslcClient
-
createResource
public javax.ws.rs.core.Response createResource(String url, Object artifact, String mediaType, String acceptType, String configurationContext)
- Specified by:
createResourcein interfaceIOslcClient
-
updateResource
public javax.ws.rs.core.Response updateResource(String url, Object artifact, String mediaType)
Description copied from interface:IOslcClientUpdate (PUT) an artifact to a URL - usually the URL for an existing OSLC artifact- Specified by:
updateResourcein interfaceIOslcClient
-
updateResource
public javax.ws.rs.core.Response updateResource(String url, Object artifact, String mediaType, String acceptType)
Description copied from interface:IOslcClientUpdate (PUT) an artifact to a URL - usually the URL for an existing OSLC artifact- Specified by:
updateResourcein interfaceIOslcClient
-
updateResource
public javax.ws.rs.core.Response updateResource(String url, Object artifact, String mediaType, String acceptType, String ifMatch)
Description copied from interface:IOslcClientUpdate (PUT) an artifact to a URL - usually the URL for an existing OSLC artifact- Specified by:
updateResourcein interfaceIOslcClient
-
updateResource
public javax.ws.rs.core.Response updateResource(String url, Object artifact, String mediaType, String acceptType, String ifMatch, String configurationContext)
- Specified by:
updateResourcein interfaceIOslcClient
-
-