Package org.eclipse.lyo.client
Class OslcClient
- java.lang.Object
-
- org.eclipse.lyo.client.OslcClient
-
- All Implemented Interfaces:
IOslcClient
public class OslcClient extends Object implements IOslcClient
An OSLC Client that extends the JAX-RS 2.0 REST client with OSLC specific CRUD and discovery capabilities. Client applications would typically provide a ClientBuilder to the constructor to configure the REST client too meet their needs.
-
-
Constructor Summary
Constructors Constructor Description OslcClient()A simple OslcClient that provides http access to unprotected resourcesOslcClient(String version)OslcClient(ClientBuilder clientBuilder)An OslcClient that allows client applications to provide a configured (but not built) ClientBuilder typically used for supporting https, and various kinds of authentication.OslcClient(ClientBuilder clientBuilder, String version)An OslcClient that allows client applications to provide a configured (but not built) ClientBuilder typically used for supporting https, and various kinds of authentication.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResponsecreateResource(String url, Object artifact, String mediaType)Create (POST) an artifact to a URL - usually an OSLC Creation FactoryResponsecreateResource(String url, Object artifact, String mediaType, String acceptType)Create (POST) an artifact to a URL - usually an OSLC Creation FactoryResponsecreateResource(String url, Object artifact, String mediaType, String acceptType, String configurationContext)ResponsedeleteResource(String url)Delete an OSLC resource and return a Wink ClientResponseResponsedeleteResource(String url, String configurationContext)ClientgetClient()Returns the JAX-RS client for this OslcClient.ResponsegetResource(String url)Gets an OSLC resource usingapplication/rdf+xml.<T> TgetResource(String link, Class<T> clazz)Gets an OSLC resource from a given URI string and unwraps a corresponding entity.ResponsegetResource(String url, String mediaType)Gets an OSLC resource.ResponsegetResource(String url, Map<String,String> requestHeaders)Gets an OSLC resource.ResponsegetResource(String url, Map<String,String> requestHeaders, String defaultMediaType)ResponsegetResource(String url, Map<String,String> requestHeaders, String defaultMediaType, boolean handleRedirects)ResponsegetResource(String url, Map<String,String> requestHeaders, String defaultMediaType, String configurationContext)ResponsegetResource(String url, Map<String,String> requestHeaders, String defaultMediaType, String configurationContext, boolean handleRedirects)<T> TgetResource(URI link, Class<T> clazz)Gets an OSLC resource from a given URI and unwraps a corresponding entity.<T> TgetResource(Link link, Class<T> clazz)Gets an OSLC resource from a URI in a given Link and unwraps a corresponding entity.<T> List<T>getResources(URI[] links, Class<T> clazz)Gets OSLC resources in parallel from an array of URIs and unwraps their corresponding entities.<T> List<T>getResources(Collection<URI> links, Class<T> clazz)Gets OSLC resources in parallel from a collection of URIs and unwraps their corresponding entities.<T> List<T>getResourcesFromLinks(Collection<Link> links, Class<T> clazz)Gets OSLC resources in parallel from a set of Links and unwraps their corresponding entities.WebTargetgetWebResource(String capabilityUri)Create a Wink Resource for the given OslcQuery objectStringlookupCreationFactory(String serviceProviderUrl, String oslcDomain, String oslcResourceType)Find the OSLC Creation Factory URL for a given OSLC resource type.StringlookupCreationFactory(String serviceProviderUrl, String oslcDomain, String oslcResourceType, String oslcUsage)Find the OSLC Creation Factory URL for a given OSLC resource type and OSLC usage.CreationFactorylookupCreationFactoryResource(String serviceProviderUrl, String oslcDomain, String oslcResourceType)CreationFactorylookupCreationFactoryResource(String serviceProviderUrl, String oslcDomain, String oslcResourceType, String oslcUsage)StringlookupQueryCapability(String serviceProviderUrl, String oslcDomain, String oslcResourceType)Find the OSLC Query Capability URL for a given OSLC resource type.StringlookupServiceProviderUrl(String catalogUrl, String serviceProviderTitle)Lookup the URL of a specific OSLC Service Provider in an OSLC Catalog using the service provider's titleResponseupdateResource(String url, Object artifact, String mediaType)Update (PUT) an artifact to a URL - usually the URL for an existing OSLC artifactResponseupdateResource(String url, Object artifact, String mediaType, String acceptType)Update (PUT) an artifact to a URL - usually the URL for an existing OSLC artifactResponseupdateResource(String url, Object artifact, String mediaType, String acceptType, String ifMatch)Update (PUT) an artifact to a URL - usually the URL for an existing OSLC artifactResponseupdateResource(String url, Object artifact, String mediaType, String acceptType, String ifMatch, String configurationContext)
-
-
-
Constructor Detail
-
OslcClient
public OslcClient()
A simple OslcClient that provides http access to unprotected resources
-
OslcClient
public OslcClient(String version)
- Parameters:
version- OSLC version, seeOSLCConstants
-
OslcClient
public OslcClient(ClientBuilder clientBuilder)
An OslcClient that allows client applications to provide a configured (but not built) ClientBuilder typically used for supporting https, and various kinds of authentication.- Parameters:
clientBuilder- HTTP client configuration
-
OslcClient
public OslcClient(ClientBuilder clientBuilder, String version)
An OslcClient that allows client applications to provide a configured (but not built) ClientBuilder typically used for supporting https, and various kinds of authentication.- Parameters:
clientBuilder- HTTP client configurationversion- OSLC version, seeOSLCConstants
-
-
Method Detail
-
getClient
public Client getClient()
Returns the JAX-RS client for this OslcClient. Do not touch unless needed.- Specified by:
getClientin interfaceIOslcClient- Returns:
- the JAX-RS client
-
getResource
public <T> T getResource(String link, Class<T> clazz)
Gets an OSLC resource from a given URI string and unwraps a corresponding entity.
-
getResource
public <T> T getResource(URI link, Class<T> clazz)
Gets an OSLC resource from a given URI and unwraps a corresponding entity.
-
getResource
public <T> T getResource(Link link, Class<T> clazz)
Gets an OSLC resource from a URI in a given Link and unwraps a corresponding entity.
-
getResources
public <T> List<T> getResources(URI[] links, Class<T> clazz)
Gets OSLC resources in parallel from an array of URIs and unwraps their corresponding entities.
-
getResources
public <T> List<T> getResources(Collection<URI> links, Class<T> clazz)
Gets OSLC resources in parallel from a collection of URIs and unwraps their corresponding entities.
-
getResourcesFromLinks
public <T> List<T> getResourcesFromLinks(Collection<Link> links, Class<T> clazz)
Gets OSLC resources in parallel from a set of Links and unwraps their corresponding entities.Method renamed due to type erasure in Java
-
getResource
public Response getResource(String url)
Gets an OSLC resource usingapplication/rdf+xml. UsegetResource(String, String)to specify the media type orgetResource(String, Map)to add other request headers.- Specified by:
getResourcein interfaceIOslcClient
-
getResource
public Response getResource(String url, String mediaType)
Gets an OSLC resource. UsegetResource(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 Response getResource(String url, Map<String,String> requestHeaders)
Gets 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 Response getResource(String url, Map<String,String> requestHeaders, String defaultMediaType)
- Specified by:
getResourcein interfaceIOslcClient
-
getResource
public Response getResource(String url, Map<String,String> requestHeaders, String defaultMediaType, String configurationContext)
- Specified by:
getResourcein interfaceIOslcClient
-
getResource
public Response getResource(String url, Map<String,String> requestHeaders, String defaultMediaType, boolean handleRedirects)
- Specified by:
getResourcein interfaceIOslcClient
-
getResource
public Response getResource(String url, Map<String,String> requestHeaders, String defaultMediaType, String configurationContext, boolean handleRedirects)
- Specified by:
getResourcein interfaceIOslcClient
-
deleteResource
public Response deleteResource(String url)
Delete an OSLC resource and return a Wink ClientResponse- Specified by:
deleteResourcein interfaceIOslcClient- Parameters:
url-
-
deleteResource
public Response deleteResource(String url, String configurationContext)
- Specified by:
deleteResourcein interfaceIOslcClient
-
createResource
public Response createResource(String url, Object artifact, String mediaType)
Create (POST) an artifact to a URL - usually an OSLC Creation Factory- Specified by:
createResourcein interfaceIOslcClient
-
createResource
public Response createResource(String url, Object artifact, String mediaType, String acceptType)
Create (POST) an artifact to a URL - usually an OSLC Creation Factory- Specified by:
createResourcein interfaceIOslcClient
-
createResource
public Response createResource(String url, Object artifact, String mediaType, String acceptType, String configurationContext)
- Specified by:
createResourcein interfaceIOslcClient
-
updateResource
public Response updateResource(String url, Object artifact, String mediaType)
Update (PUT) an artifact to a URL - usually the URL for an existing OSLC artifact- Specified by:
updateResourcein interfaceIOslcClient
-
updateResource
public Response updateResource(String url, Object artifact, String mediaType, String acceptType)
Update (PUT) an artifact to a URL - usually the URL for an existing OSLC artifact- Specified by:
updateResourcein interfaceIOslcClient
-
updateResource
public Response updateResource(String url, Object artifact, String mediaType, String acceptType, String ifMatch)
Update (PUT) an artifact to a URL - usually the URL for an existing OSLC artifact- Specified by:
updateResourcein interfaceIOslcClient
-
updateResource
public Response updateResource(String url, Object artifact, String mediaType, String acceptType, String ifMatch, String configurationContext)
- Specified by:
updateResourcein interfaceIOslcClient
-
getWebResource
public WebTarget getWebResource(String capabilityUri)
Create a Wink Resource for the given OslcQuery object
-
lookupServiceProviderUrl
public String lookupServiceProviderUrl(String catalogUrl, String serviceProviderTitle) throws IOException, URISyntaxException, ResourceNotFoundException
Lookup the URL of a specific OSLC Service Provider in an OSLC Catalog using the service provider's title
-
lookupQueryCapability
public String lookupQueryCapability(String serviceProviderUrl, String oslcDomain, String oslcResourceType) throws IOException, URISyntaxException, ResourceNotFoundException
Find the OSLC Query Capability URL for a given OSLC resource type. If no resource type is given, returns the default Query Capability, if it exists.- Parameters:
oslcResourceType- - the resource type of the desired query capability. This may differ from the OSLC artifact type.- Returns:
- URL of requested Query Capability or null if not found.
- Throws:
IOExceptionURISyntaxExceptionResourceNotFoundException
-
lookupCreationFactoryResource
public CreationFactory lookupCreationFactoryResource(String serviceProviderUrl, String oslcDomain, String oslcResourceType) throws IOException, URISyntaxException, ResourceNotFoundException
-
lookupCreationFactoryResource
public CreationFactory lookupCreationFactoryResource(String serviceProviderUrl, String oslcDomain, String oslcResourceType, String oslcUsage) throws IOException, URISyntaxException, ResourceNotFoundException
-
lookupCreationFactory
public String lookupCreationFactory(String serviceProviderUrl, String oslcDomain, String oslcResourceType) throws IOException, URISyntaxException, ResourceNotFoundException
Find the OSLC Creation Factory URL for a given OSLC resource type. If no resource type is given, returns the default Creation Factory, if it exists.- Parameters:
oslcResourceType- - the resource type of the desired query capability. This may differ from the OSLC artifact type.- Returns:
- URL of requested Creation Factory or null if not found.
- Throws:
IOExceptionURISyntaxExceptionResourceNotFoundException
-
lookupCreationFactory
public String lookupCreationFactory(String serviceProviderUrl, String oslcDomain, String oslcResourceType, String oslcUsage) throws IOException, URISyntaxException, ResourceNotFoundException
Find the OSLC Creation Factory URL for a given OSLC resource type and OSLC usage. If no resource type is given, returns the default Creation Factory, if it exists.- Parameters:
oslcResourceType- - the resource type of the desired query capability. This may differ from the OSLC artifact type.- Returns:
- URL of requested Creation Factory or null if not found.
- Throws:
IOExceptionURISyntaxExceptionResourceNotFoundException
-
-