Class TLcdCSWClient
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:
- GetRecords:
createGetRecordsRequest()
To send requests to the server and receive the response, the following methods can be used:
- GetCapabilities:
getCapabilities()
- GetRecords:
getRecords(TLcdCSWGetRecordsRequest)
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 Summary
Modifier and TypeMethodDescriptionstatic TLcdCSWClient
createCSWClient
(URI aURI) Creates a new CSW client using the specified URI.static TLcdCSWClient
createCSWClient
(URI aURI, ILcdOWSTransport aTransport, Object aTransportData) Creates a new CSW client using the specified URI.static TLcdCSWClient
createCSWClient
(URI aURI, ILcdOWSTransport aTransport, Object aTransportData, Collection<TLcdDataModel> aUsedDataModels) Creates a new CSW client using the specified URI.Creates a GetRecords request initialized with the negotiated version of the current server.Returns the capabilities of the connected CSW server.getRecords
(TLcdCSWGetRecordsRequest aRequest) Sends the given GetRecords request to the server.getURI()
Returns the URI of the CSW server.
-
Method Details
-
createCSWClient
public static TLcdCSWClient createCSWClient(URI aURI) throws TLcdOWSServerException, TLcdOWSDecodingException, TLcdOWSTransportException, TLcdOWSUnsupportedVersionException 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 nullIllegalArgumentException
- if the specified URI is not compatible with the default transportTLcdOWSServerException
- if the server returned an OpenGIS Web Service exceptionTLcdOWSDecodingException
- if an error occurs while decoding the initial CSW responseTLcdOWSTransportException
- if an error occurs in the transport layer while negotiation the versionTLcdOWSUnsupportedVersionException
- if the specified CSW server does not support any of the CSW versions implemented by this client
-
createCSWClient
public static TLcdCSWClient createCSWClient(URI aURI, ILcdOWSTransport aTransport, Object aTransportData) throws TLcdOWSServerException, TLcdOWSDecodingException, TLcdOWSTransportException, TLcdOWSUnsupportedVersionException 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 serveraTransport
- the transport to useaTransportData
- 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 nullIllegalArgumentException
- if the specified URI is not compatible with the specified transportTLcdOWSServerException
- if the server returned an OpenGIS Web Service exceptionTLcdOWSDecodingException
- if an error occurs while decoding the initial CSW responseTLcdOWSTransportException
- if an error occurs in the transport layer while negotiation the versionTLcdOWSUnsupportedVersionException
- if the specified CSW server does not support any of the CSW versions implemented by this client
-
createCSWClient
public static TLcdCSWClient createCSWClient(URI aURI, ILcdOWSTransport aTransport, Object aTransportData, Collection<TLcdDataModel> aUsedDataModels) throws TLcdOWSServerException, TLcdOWSDecodingException, TLcdOWSTransportException, TLcdOWSUnsupportedVersionException 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 serveraTransport
- the transport to useaTransportData
- 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 nullIllegalArgumentException
- if the specified URI is not compatible with the specified transportTLcdOWSServerException
- if the server returned an OpenGIS Web Service exceptionTLcdOWSDecodingException
- if an error occurs while decoding the initial CSW responseTLcdOWSTransportException
- if an error occurs in the transport layer while negotiation the versionTLcdOWSUnsupportedVersionException
- if the specified CSW server does not support any of the CSW versions implemented by this client
-
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 aGetCapabilities
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
Creates a GetRecords request initialized with the negotiated version of the current server.- Returns:
- an empty request
-
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
public TLcdCSWGetRecordsResponse getRecords(TLcdCSWGetRecordsRequest aRequest) throws IOException, XMLStreamException 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 failsIOException
-