Changeset 2959 for SRUClient


Ignore:
Timestamp:
05/29/13 18:32:21 (11 years ago)
Author:
oschonef
Message:
  • add constructor for SRU*Request that accepts an URI object
Location:
SRUClient/trunk/src/main/java/eu/clarin/sru/client
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUAbstractRequest.java

    r2955 r2959  
    109109        }
    110110    } // class URIHelper
    111     /** The URL of the endpoint. */
    112     protected final String endpointURI;
     111    /** The baseURI of the SRU server. */
     112    protected final URI baseURI;
    113113    /**
    114114     * The request should be processed in strict or non-strict SRU protocol
     
    126126     * Constructor.
    127127     *
    128      * @param endpointURI
    129      *            the URI of the endpoint
     128     * @param baseURI
     129     *            the baseURI of the SRU server
    130130     * @throws NullPointerException
    131131     *             if any required argument is null
    132132     */
    133     protected SRUAbstractRequest(String endpointURI) {
    134         if (endpointURI == null) {
    135             throw new NullPointerException("endpointURI == null");
    136         }
    137         this.endpointURI = endpointURI;
    138     }
    139 
    140 
    141     /**
    142      * Get the endpoint URI.
    143      *
    144      * @return the endpoint URI
    145      */
    146     public String getEndpointURI() {
    147         return endpointURI;
     133    protected SRUAbstractRequest(URI baseURI) {
     134        if (baseURI == null) {
     135            throw new NullPointerException("baseURI == null");
     136        }
     137        this.baseURI = baseURI;
     138    }
     139
     140
     141    /**
     142     * Constructor.
     143     *
     144     * @param baseURI
     145     *            the baseURI of the SRU server
     146     * @throws NullPointerException
     147     *             if any required argument is null
     148     * @throw IllegalArgumentException if the URI is invalid
     149     */
     150    protected SRUAbstractRequest(String baseURI) {
     151        if (baseURI == null) {
     152            throw new NullPointerException("baseURI == null");
     153        }
     154        if (baseURI.isEmpty()) {
     155            throw new IllegalArgumentException("baseURI is empty");
     156        }
     157        try {
     158            this.baseURI = new URI(baseURI);
     159        } catch (URISyntaxException e) {
     160            throw new IllegalArgumentException("invalid URI", e);
     161        }
     162    }
     163
     164
     165    /**
     166     * Get the baseURI of the SRU server.
     167     *
     168     * @return the baseURI of the SRU server
     169     */
     170    public URI getBaseURI() {
     171        return baseURI;
    148172    }
    149173
     
    278302        try {
    279303            final URIHelper uriBuilder =
    280                     new URIHelper(new URIBuilder(endpointURI));
     304                    new URIHelper(new URIBuilder(baseURI));
    281305
    282306            /*
     
    285309             * NB: Setting "x-malformed-operation" as an extra request parameter
    286310             * makes the client to send invalid requests. This is intended to
    287              * use for testing endpoints for protocol conformance (i.e. provoke
    288              * an error) and SHOULD NEVER be used in production!
     311             * use for testing SRU servers for protocol conformance (i.e.
     312             * provoke an error) and SHOULD NEVER be used in production!
    289313             */
    290314            final String malformedOperation =
     
    316340             * NB: Setting "x-malformed-version" as an extra request parameter
    317341             * makes the client to send invalid requests. This is intended to
    318              * use for testing endpoints for protocol conformance (i.e. provoke
    319              * an error) and SHOULD NEVER be used in production!
     342             * use for testing SRU servers for protocol conformance (i.e.
     343             * provoke an error) and SHOULD NEVER be used in production!
    320344             */
    321345            final String malformedVersion =
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUExplainRequest.java

    r2948 r2959  
    1717package eu.clarin.sru.client;
    1818
     19import java.net.URI;
     20
    1921/**
    2022 * An object for performing a <em>explain</em> operation.
     
    3335     *            the baseURI of the endpoint
    3436     */
     37    public SRUExplainRequest(URI baseURI) {
     38        super(baseURI);
     39    }
     40
     41
     42    /**
     43     * Constructor.
     44     *
     45     * @param baseURI
     46     *            the baseURI of the endpoint
     47     */
    3548    public SRUExplainRequest(String baseURI) {
    3649        super(baseURI);
     
    4053    /**
    4154     * Set the requested record packing.
    42      *
     55     * 
    4356     * @param recordPacking
    4457     *            the requested record packing
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUScanRequest.java

    r2948 r2959  
    1616 */
    1717package eu.clarin.sru.client;
     18
     19import java.net.URI;
    1820
    1921/**
     
    4951     *            the baseURI of the endpoint
    5052     */
     53    public SRUScanRequest(URI baseURI) {
     54        super(baseURI);
     55    }
     56
     57   
     58    /**
     59     * Constructor.
     60     *
     61     * @param baseURI
     62     *            the baseURI of the endpoint
     63     */
    5164    public SRUScanRequest(String baseURI) {
    5265        super(baseURI);
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUSearchRetrieveRequest.java

    r2948 r2959  
    1616 */
    1717package eu.clarin.sru.client;
     18
     19import java.net.URI;
    1820
    1921/**
     
    5759     *            the baseURI of the endpoint
    5860     */
     61    public SRUSearchRetrieveRequest(URI baseURI) {
     62        super(baseURI);
     63    }
     64
     65
     66    /**
     67     * Constructor.
     68     *
     69     * @param baseURI
     70     *            the baseURI of the endpoint
     71     */
    5972    public SRUSearchRetrieveRequest(String baseURI) {
    6073        super(baseURI);
Note: See TracChangeset for help on using the changeset viewer.