Class TLcdCSWClient

java.lang.Object
com.luciad.ogc.csw.client.TLcdCSWClient

public class TLcdCSWClient extends Object
Allows connecting to an OGC catalog service. The supported CSW versions are 2.0.2 and 3.0.0.

A new TLcdCSWClient instance can be created by invoking one of the static factory methods. To customize the communication between client and server, an ILcdOWSTransport can optionally be provided. This interface represents the transport layer, and can be used to choose the communication protocol (HTTP GET, HTTP POST, ...), add authentication, or configure any other parameter that relates to the communication channel. By default, an instance of TLcdOWSHttpTransport is used.

Once a TLcdCSWClient instance is initialized, the following requests can be created:

To send requests to the server and receive the response, the following methods can be used:

Upon initialization, TLcdCSWClient automatically performs a version negotiation process with the server to agree on the version number. All created requests are initialized with the agreed version number, and should therefore only be used by the TLcdCSWClient instance that created them.

Since:
2017.0
See Also:
  • Method Details

    • createCSWClient

      Creates a new CSW client using the specified URI. The CSW client will use the default transport (HTTP).
      Parameters:
      aURI - the URI of the CSW server
      Returns:
      a new CSW client
      Throws:
      NullPointerException - if the URI is null
      IllegalArgumentException - if the specified URI is not compatible with the default transport
      TLcdOWSServerException - if the server returned an OpenGIS Web Service exception
      TLcdOWSDecodingException - if an error occurs while decoding the initial CSW response
      TLcdOWSTransportException - if an error occurs in the transport layer while negotiation the version
      TLcdOWSUnsupportedVersionException - if the specified CSW server does not support any of the CSW versions implemented by this client
    • createCSWClient

      Creates a new CSW client using the specified URI. The CSW client will use the specified transport. This method will retrieve the capabilities description from the CSW server at the specified URI. Depending on the response of the CSW server this method will then perform the version negotiation process described in the CSW specification. These initial capabilities requests will use the specified transport data, if not null. Transport data can for example be used to supply authentication information, if required by the server. The CSW client returned by this method is guaranteed to be compatible with the CSW version supported by the CSW server.
      Parameters:
      aURI - the URI of the CSW server
      aTransport - the transport to use
      aTransportData - the transport data to use for the initial capabilities requests (may be null)
      Returns:
      a new CSW client
      Throws:
      NullPointerException - if either the URI or the transport is null
      IllegalArgumentException - if the specified URI is not compatible with the specified transport
      TLcdOWSServerException - if the server returned an OpenGIS Web Service exception
      TLcdOWSDecodingException - if an error occurs while decoding the initial CSW response
      TLcdOWSTransportException - if an error occurs in the transport layer while negotiation the version
      TLcdOWSUnsupportedVersionException - if the specified CSW server does not support any of the CSW versions implemented by this client
    • createCSWClient

      Creates a new CSW client using the specified URI. The CSW client will use the specified transport. This method will retrieve the capabilities description from the CSW server at the specified URI. Depending on the response of the CSW server this method will then perform the version negotiation process described in the CSW specification. These initial capabilities requests will use the specified transport data, if not null. Transport data can for example be used to supply authentication information, if required by the server. The CSW client returned by this method is guaranteed to be compatible with the CSW version supported by the CSW server.
      Parameters:
      aURI - the URI of the CSW server
      aTransport - the transport to use
      aTransportData - the transport data to use for the initial capabilities requests (may be null)
      aUsedDataModels - additional data models used by this client (such as AIXM, GML), or null
      Returns:
      a new CSW client
      Throws:
      NullPointerException - if either the URI or the transport is null
      IllegalArgumentException - if the specified URI is not compatible with the specified transport
      TLcdOWSServerException - if the server returned an OpenGIS Web Service exception
      TLcdOWSDecodingException - if an error occurs while decoding the initial CSW response
      TLcdOWSTransportException - if an error occurs in the transport layer while negotiation the version
      TLcdOWSUnsupportedVersionException - if the specified CSW server does not support any of the CSW versions implemented by this client
    • getURI

      public URI getURI()
      Returns the URI of the CSW server. If no URI was specified at construction, the URI is determined from the capabilities: as each OGC Web Service should support a GetCapabilities request, the address associated with this request is used. If the GET request method is supported, the corresponding address is used; otherwise, it is assumed that the POST request method is supported and the corresponding address is used; if this check also fails, null is returned and the client will not be able to connect with the CSW server.
      Returns:
      the URI of the CSW server.
    • createGetRecordsRequest

      public TLcdCSWGetRecordsRequest createGetRecordsRequest()
      Creates a GetRecords request initialized with the negotiated version of the current server.
      Returns:
      an empty request
    • getCapabilities

      public TLcdCSWCapabilities getCapabilities()
      Returns the capabilities of the connected CSW server.
      Subsequent calls will always return the same capabilities, it does not re-connect to the CSW to refresh the capabilities. If you need to refresh the capabilities, create a new client.
      Returns:
      The capabilities retrieved from the CSW server.
    • getRecords

      Sends the given GetRecords request to the server. A minimal CSW 3.0 request for all metadata records is as follows:
      
       TLcdCSWGetRecordsRequest request = new TLcdCSWGetRecordsRequest("3.0.0");
       TLcdCSWQuery query = new TLcdCSWQuery();
       query.getTypeNames().add(TLcdCSWRecordType.CSW_300.getTypeName());
       query.setElementSetName(TLcdCSWElementSetName.FULL);
       request.setQuery(query);
       TLcdCSWGetRecordsResponse records = client.getRecords(request);
       
      Parameters:
      aRequest - the request to pass to the server
      Returns:
      The response containing the records, if any
      Throws:
      XMLStreamException - if the decoding of the result fails
      IOException