org.eclipse.lyo.client.oslc

## Class OslcClient

- java.lang.Object
- - org.eclipse.lyo.client.oslc.OslcClient

- Direct Known Subclasses:
    JazzFormAuthClient, OslcOAuthClient

      public class OslcClient
      extends Object

  An OSLC Client. Provides an Apache HttpClient, an Apache Wink REST ClientConfig and defines a getResource method which returns an Apache Wink ClientResponse.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `OslcClient.OAuthHttpPool`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.apache.http.impl.client.DefaultHttpClient` | `httpClient`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `OslcClient()` Initialize a new OslcClient using an Apache Http Components 4 Http client and configuration.
    `OslcClient(TrustManager[] trustManagers, org.apache.http.conn.ssl.X509HostnameVerifier hostnameVerifier)` Initialize a new OslcClient using an Apache Http Components 4 Http client and configuration.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `org.apache.wink.client.ClientResponse` | `createResource(String url, Object artifact, String mediaType)` Create (POST) an artifact to a URL - usually an OSLC Creation Factory
    `org.apache.wink.client.ClientResponse` | `createResource(String url, Object artifact, String mediaType, String acceptType)` Create (POST) an artifact to a URL - usually an OSLC Creation Factory
    `org.apache.wink.client.ClientResponse` | `deleteResource(String url)` Delete an OSLC resource and return a Wink ClientResponse
    `protected org.apache.wink.client.ClientConfig` | `getClientConfig()`
    `protected net.oauth.client.httpclient4.HttpClientPool` | `getClientPool()`
    `String` | `getConfiguredSecureSocketProtocol()` Sets the Secure Socket Protocol to be used, valid values "TLS","SSL","SSL_TLS".
    `org.apache.http.client.HttpClient` | `getHttpClient()` Returns the HTTP client associated with this OSLC Client
    `org.apache.wink.client.Resource` | `getQueryResource(OslcQuery query)` Create a Wink Resource for the given OslcQuery object
    `org.apache.wink.client.ClientResponse` | `getResource(String url)` Gets an OSLC resource using `application/rdf+xml`.
    `org.apache.wink.client.ClientResponse` | `getResource(String url, Map<String,String> requestHeaders)` Gets an OSLC resource.
    `protected org.apache.wink.client.ClientResponse` | `getResource(String url, Map<String,String> requestHeaders, String defaultMediaType)`
    `org.apache.wink.client.ClientResponse` | `getResource(String url, String mediaType)` Gets an OSLC resource.
    `String` | `lookupCreationFactory(String serviceProviderUrl, String oslcDomain, String oslcResourceType)` Find the OSLC Creation Factory URL for a given OSLC resource type.
    `String` | `lookupCreationFactory(String serviceProviderUrl, String oslcDomain, String oslcResourceType, String oslcUsage)` Find the OSLC Creation Factory URL for a given OSLC resource type and OSLC usage.
    `org.eclipse.lyo.oslc4j.core.model.CreationFactory` | `lookupCreationFactoryResource(String serviceProviderUrl, String oslcDomain, String oslcResourceType)`
    `org.eclipse.lyo.oslc4j.core.model.CreationFactory` | `lookupCreationFactoryResource(String serviceProviderUrl, String oslcDomain, String oslcResourceType, String oslcUsage)`
    `String` | `lookupQueryCapability(String serviceProviderUrl, String oslcDomain, String oslcResourceType)` Find the OSLC Query Capability URL for a given OSLC resource type.
    `String` | `lookupServiceProviderUrl(String catalogUrl, String serviceProviderTitle)` Lookup the URL of a specific OSLC Service Provider in an OSLC Catalog using the service provider's title
    `void` | `setConfiguredSecureSocketProtocol(String configuredSecureSocketProtocol)` Returns theSecure Sockect Protocol associated with this OSLC Client
    `org.apache.wink.client.ClientResponse` | `updateResource(String url, Object artifact, String mediaType)` Update (PUT) an artifact to a URL - usually the URL for an existing OSLC artifact
    `org.apache.wink.client.ClientResponse` | `updateResource(String url, Object artifact, String mediaType, String acceptType)` Update (PUT) an artifact to a URL - usually the URL for an existing OSLC artifact
    `org.apache.wink.client.ClientResponse` | `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

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### httpClient

          protected org.apache.http.impl.client.DefaultHttpClient httpClient

  - ### Constructor Detail

    - #### OslcClient

          public OslcClient()

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

    - #### OslcClient

          public OslcClient(TrustManager[] trustManagers,
                    org.apache.http.conn.ssl.X509HostnameVerifier hostnameVerifier)

      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;

  - ### Method Detail

    - #### getConfiguredSecureSocketProtocol

          public String getConfiguredSecureSocketProtocol()

      Sets the Secure Socket Protocol to be used, valid values "TLS","SSL","SSL_TLS".

    - #### setConfiguredSecureSocketProtocol

          public void setConfiguredSecureSocketProtocol(String configuredSecureSocketProtocol)

      Returns theSecure Sockect Protocol associated with this OSLC Client

    - #### getHttpClient

          public org.apache.http.client.HttpClient getHttpClient()

      Returns the HTTP client associated with this OSLC Client
      Returns:
        the HTTP client

    - #### getClientPool

          protected net.oauth.client.httpclient4.HttpClientPool getClientPool()

    - #### getClientConfig

          protected org.apache.wink.client.ClientConfig getClientConfig()

    - #### getResource

          public org.apache.wink.client.ClientResponse getResource(String url)
                                                            throws IOException,
                                                                   net.oauth.OAuthException,
                                                                   URISyntaxException

      Gets an OSLC resource using `application/rdf+xml`. Use `getResource(String, String)` to specify the media type or `getResource(String, Map)` to add other request headers. Call `ClientResponse.getEntity(Class)` on the response to get the OSLC4J-annotated Java object.
      Parameters:
        `url` - the resource URL
      Returns:
        the Apache Wink ClientResponse
      Throws:
        `IOException`
        `net.oauth.OAuthException`
        `URISyntaxException`

    - #### getResource

          public org.apache.wink.client.ClientResponse getResource(String url,
                                                          String mediaType)
                                                            throws IOException,
                                                                   net.oauth.OAuthException,
                                                                   URISyntaxException

      Gets an OSLC resource. Use `getResource(String, Map)` instead to add other request headers. Call `ClientResponse.getEntity(Class)` on the response to get the OSLC4J-annotated Java object.
      Parameters:
        `url` - the resource URL
        `mediaType` - the requested media type to use in the HTTP Accept request header
      Returns:
        the Apache Wink ClientResponse
      Throws:
        `IOException`
        `net.oauth.OAuthException`
        `URISyntaxException`

    - #### getResource

          public org.apache.wink.client.ClientResponse getResource(String url,
                                                          Map<String,String> requestHeaders)

      Gets an OSLC resource. Call `ClientResponse.getEntity(Class)` on the response to get the OSLC4J-annotated Java object.
      Parameters:
        `url` - the resource URL
        `requestHeaders` - the HTTP request headers to use. If the `Accept` header is not in the map, it defaults to `application/rdf+xml`. If `OSLC-Core-Version` is not in the map, it defaults to `2.0`.
      Returns:
        the Apache Wink ClientResponse
      Throws:
        `IOException`
        `net.oauth.OAuthException`
        `URISyntaxException`

    - #### getResource

          protected org.apache.wink.client.ClientResponse getResource(String url,
                                                          Map<String,String> requestHeaders,
                                                          String defaultMediaType)

    - #### deleteResource

          public org.apache.wink.client.ClientResponse deleteResource(String url)
                                                               throws IOException,
                                                                      net.oauth.OAuthException,
                                                                      URISyntaxException

      Delete an OSLC resource and return a Wink ClientResponse
      Parameters:
        `url` -
      Returns:
        a Wink ClientResponse
      Throws:
        `IOException`
        `net.oauth.OAuthException`
        `URISyntaxException`

    - #### createResource

          public org.apache.wink.client.ClientResponse createResource(String url,
                                                             Object artifact,
                                                             String mediaType)
                                                               throws IOException,
                                                                      net.oauth.OAuthException,
                                                                      URISyntaxException

      Create (POST) an artifact to a URL - usually an OSLC Creation Factory
      Parameters:
        `url` -
        `artifact` -
        `mediaType` -
      Returns:
      Throws:
        `URISyntaxException`
        `net.oauth.OAuthException`
        `IOException`

    - #### createResource

          public org.apache.wink.client.ClientResponse createResource(String url,
                                                             Object artifact,
                                                             String mediaType,
                                                             String acceptType)
                                                               throws IOException,
                                                                      net.oauth.OAuthException,
                                                                      URISyntaxException

      Create (POST) an artifact to a URL - usually an OSLC Creation Factory
      Parameters:
        `url` -
        `artifact` -
        `mediaType` -
        `acceptType` -
      Returns:
      Throws:
        `URISyntaxException`
        `net.oauth.OAuthException`
        `IOException`

    - #### updateResource

          public org.apache.wink.client.ClientResponse updateResource(String url,
                                                             Object artifact,
                                                             String mediaType)

      Update (PUT) an artifact to a URL - usually the URL for an existing OSLC artifact
      Parameters:
        `url` -
        `artifact` -
        `mediaType` -
      Returns:

    - #### updateResource

          public org.apache.wink.client.ClientResponse updateResource(String url,
                                                             Object artifact,
                                                             String mediaType,
                                                             String acceptType)

      Update (PUT) an artifact to a URL - usually the URL for an existing OSLC artifact
      Parameters:
        `url` -
        `artifact` -
        `mediaType` -
        `acceptType` -
      Returns:

    - #### updateResource

          public org.apache.wink.client.ClientResponse updateResource(String url,
                                                             Object artifact,
                                                             String mediaType,
                                                             String acceptType,
                                                             String ifMatch)
                                                               throws IOException,
                                                                      net.oauth.OAuthException,
                                                                      URISyntaxException

      Update (PUT) an artifact to a URL - usually the URL for an existing OSLC artifact
      Parameters:
        `url` -
        `artifact` -
        `mediaType` -
        `acceptType` -
      Returns:
      Throws:
        `URISyntaxException`
        `net.oauth.OAuthException`
        `IOException`

    - #### getQueryResource

          public org.apache.wink.client.Resource getQueryResource(OslcQuery query)

      Create a Wink Resource for the given OslcQuery object
      Parameters:
        `query` -
      Returns:

    - #### lookupServiceProviderUrl

          public String lookupServiceProviderUrl(String catalogUrl,
                                        String serviceProviderTitle)
                                          throws IOException,
                                                 net.oauth.OAuthException,
                                                 URISyntaxException,
                                                 ResourceNotFoundException

      Lookup the URL of a specific OSLC Service Provider in an OSLC Catalog using the service provider's title
      Parameters:
        `catalogUrl` -
        `serviceProviderTitle` -
      Returns:
      Throws:
        `IOException`
        `net.oauth.OAuthException`
        `URISyntaxException`
        `ResourceNotFoundException`

    - #### lookupQueryCapability

          public String lookupQueryCapability(String serviceProviderUrl,
                                     String oslcDomain,
                                     String oslcResourceType)
                                       throws IOException,
                                              net.oauth.OAuthException,
                                              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:
        `serviceProviderUrl` -
        `oslcDomain` -
        `oslcResourceType` - - the resource type of the desired query capability. This may differ from the OSLC artifact type.
      Returns:
        URL of requested Query Capablility or null if not found.
      Throws:
        `IOException`
        `net.oauth.OAuthException`
        `URISyntaxException`
        `ResourceNotFoundException`

    - #### lookupCreationFactoryResource

          public org.eclipse.lyo.oslc4j.core.model.CreationFactory lookupCreationFactoryResource(String serviceProviderUrl,
                                                                                        String oslcDomain,
                                                                                        String oslcResourceType)
                                                                                          throws IOException,
                                                                                                 net.oauth.OAuthException,
                                                                                                 URISyntaxException,
                                                                                                 ResourceNotFoundException

      Throws:
        `IOException`
        `net.oauth.OAuthException`
        `URISyntaxException`
        `ResourceNotFoundException`

    - #### lookupCreationFactoryResource

          public org.eclipse.lyo.oslc4j.core.model.CreationFactory lookupCreationFactoryResource(String serviceProviderUrl,
                                                                                        String oslcDomain,
                                                                                        String oslcResourceType,
                                                                                        String oslcUsage)
                                                                                          throws IOException,
                                                                                                 net.oauth.OAuthException,
                                                                                                 URISyntaxException,
                                                                                                 ResourceNotFoundException

      Throws:
        `IOException`
        `net.oauth.OAuthException`
        `URISyntaxException`
        `ResourceNotFoundException`

    - #### lookupCreationFactory

          public String lookupCreationFactory(String serviceProviderUrl,
                                     String oslcDomain,
                                     String oslcResourceType)
                                       throws IOException,
                                              net.oauth.OAuthException,
                                              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:
        `serviceProviderUrl` -
        `oslcDomain` -
        `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:
        `IOException`
        `net.oauth.OAuthException`
        `URISyntaxException`
        `ResourceNotFoundException`

    - #### lookupCreationFactory

          public String lookupCreationFactory(String serviceProviderUrl,
                                     String oslcDomain,
                                     String oslcResourceType,
                                     String oslcUsage)
                                       throws IOException,
                                              net.oauth.OAuthException,
                                              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:
        `serviceProviderUrl` -
        `oslcDomain` -
        `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:
        `IOException`
        `net.oauth.OAuthException`
        `URISyntaxException`
        `ResourceNotFoundException`

Copyright © 2016. All Rights Reserved.