Class SRUServerConfig


  • public final class SRUServerConfig
    extends Object
    SRU server configuration.

    Example:

     URL url = MySRUServlet.class.getClassLoader()
                   .getResource("META-INF/sru-server-config.xml");
     if (url == null) {
         throw new ServletException("not found, url == null");
     }
    
     // other runtime configuration, usually obtained from Servlet context
     HashMap<String, String> params = new HashMap<String, String>();
     params.put(SRUServerConfig.SRU_TRANSPORT, "http");
     params.put(SRUServerConfig.SRU_HOST, "127.0.0.1");
     params.put(SRUServerConfig.SRU_PORT, "80");
     params.put(SRUServerConfig.SRU_DATABASE, "sru-server");
    
     SRUServerConfig config = SRUServerConfig.parse(params, url);
     

    The XML configuration file must validate against the "sru-server-config.xsd" W3C schema bundled with the package and need to have the http://www.clarin.eu/sru-server/1.0/ XML namespace.

    • Field Detail

      • SRU_SUPPORTED_VERSION_MIN

        public static final String SRU_SUPPORTED_VERSION_MIN
        Parameter constant for setting the minimum supported SRU version for this SRU server. Must be smaller or equal to SRU_SUPPORTED_VERSION_MAX.

        Valid values: "1.1", "1.2" or " 2.0" (without quotation marks)

        See Also:
        Constant Field Values
      • SRU_SUPPORTED_VERSION_MAX

        public static final String SRU_SUPPORTED_VERSION_MAX
        Parameter constant for setting the maximum supported SRU version for this SRU server. Must be larger or equal to SRU_SUPPORTED_VERSION_MIN.

        Valid values: "1.1", "1.2" or " 2.0" (without quotation marks)

        See Also:
        Constant Field Values
      • SRU_LEGACY_NAMESPACE_MODE

        public static final String SRU_LEGACY_NAMESPACE_MODE
        Parameter constant for setting the namespace URIs for SRU 1.1 and SRU 1.2.

        Valid values: "loc" for Library Of Congress URI or " oasis" for OASIS URIs (without quotation marks).

        See Also:
        Constant Field Values
      • SRU_TRANSPORT

        public static final String SRU_TRANSPORT
        Parameter constant for configuring the transports for this SRU server.

        Valid values: "http", "https" or " http https" (without quotation marks)

        Used as part of the Explain response.

        See Also:
        Constant Field Values
      • SRU_HOST

        public static final String SRU_HOST
        Parameter constant for configuring the host of this SRU server.

        Valid values: any fully qualified hostname, e.g. sru.example.org
        Used as part of the Explain response.

        See Also:
        Constant Field Values
      • SRU_PORT

        public static final String SRU_PORT
        Parameter constant for configuring the port number of this SRU server.

        Valid values: number between 1 and 65535 (typically 80 or 8080)
        Used as part of the Explain response.

        See Also:
        Constant Field Values
      • SRU_DATABASE

        public static final String SRU_DATABASE
        Parameter constant for configuring the database of this SRU server. This is usually the path component of the SRU servers URI.

        Valid values: typically the path component if the SRU server URI.
        Used as part of the Explain response.

        See Also:
        Constant Field Values
      • SRU_NUMBER_OF_RECORDS

        public static final String SRU_NUMBER_OF_RECORDS
        Parameter constant for configuring the default number of records the SRU server will provide in the response to a searchRetrieve request if the client does not provide this value.

        Valid values: a integer greater than 0 (default value is 100)

        See Also:
        Constant Field Values
      • SRU_MAXIMUM_RECORDS

        public static final String SRU_MAXIMUM_RECORDS
        Parameter constant for configuring the maximum number of records the SRU server will support in the response to a searchRetrieve request. If a client requests more records, the number will be limited to this value.

        Valid values: a integer greater than 0 (default value is 250)

        See Also:
        Constant Field Values
      • SRU_NUMBER_OF_TERMS

        public static final String SRU_NUMBER_OF_TERMS
        Parameter constant for configuring the default number of terms the SRU server will provide in the response to a scan request if the client does not provide this value.

        Valid values: a integer greater than 0 (default value is 250)

        See Also:
        Constant Field Values
      • SRU_MAXIMUM_TERMS

        public static final String SRU_MAXIMUM_TERMS
        Parameter constant for configuring the maximum number of terms the SRU server will support in the response to a scan request. If a client requests more records, the number will be limited to this value.

        Valid values: a integer greater than 0 (default value is 500)

        See Also:
        Constant Field Values
      • SRU_ECHO_REQUESTS

        public static final String SRU_ECHO_REQUESTS
        Parameter constant for configuring, if the SRU server will echo the request.

        Valid values: true or false

        See Also:
        Constant Field Values
      • SRU_INDENT_RESPONSE

        public static final String SRU_INDENT_RESPONSE
        Parameter constant for configuring, if the SRU server pretty-print the XML response. Setting this parameter can be useful for manual debugging of the XML response, however it is not recommended for production setups.

        Valid values: any integer greater or equal to -1 (default) and less or equal to 8

        See Also:
        Constant Field Values
      • SRU_ALLOW_OVERRIDE_MAXIMUM_RECORDS

        public static final String SRU_ALLOW_OVERRIDE_MAXIMUM_RECORDS
        Parameter constant for configuring, if the SRU server will allow the client to override the maximum number of records the server supports. This parameter is solely intended for debugging and setting it to true is strongly discouraged for production setups.

        Valid values: true or false (default)

        See Also:
        Constant Field Values
      • SRU_ALLOW_OVERRIDE_MAXIMUM_TERMS

        public static final String SRU_ALLOW_OVERRIDE_MAXIMUM_TERMS
        Parameter constant for configuring, if the SRU server will allow the client to override the maximum number of terms the server supports. This parameter is solely intended for debugging and setting it to true it is strongly discouraged for production setups.

        Valid values: true or false (default)

        See Also:
        Constant Field Values
      • SRU_ALLOW_OVERRIDE_INDENT_RESPONSE

        public static final String SRU_ALLOW_OVERRIDE_INDENT_RESPONSE
        Parameter constant for configuring, if the SRU server will allow the client to override the pretty-printing setting of the server. This parameter is solely intended for debugging and setting it to true it is strongly discouraged for production setups.

        Valid values: true or false (default)

        See Also:
        Constant Field Values
      • SRU_RESPONSE_BUFFER_SIZE

        public static final String SRU_RESPONSE_BUFFER_SIZE
        Parameter constant for configuring the size of response buffer. The Servlet will buffer up to this amount of data before sending a response to the client. This value specifies the size of the buffer in bytes.

        Valid values: any positive integer (default 65536)

        See Also:
        Constant Field Values
    • Method Detail

      • getMinVersion

        public SRUVersion getMinVersion()
      • getMaxVersion

        public SRUVersion getMaxVersion()
      • getDefaultVersion

        public SRUVersion getDefaultVersion()
      • getEchoRequests

        public boolean getEchoRequests()
      • getTransports

        public String getTransports()
      • getHost

        public String getHost()
      • getPort

        public int getPort()
      • getDatabase

        public String getDatabase()
      • getBaseUrl

        public String getBaseUrl()
      • getNumberOfRecords

        public int getNumberOfRecords()
      • getMaximumRecords

        public int getMaximumRecords()
      • getNumberOfTerms

        public int getNumberOfTerms()
      • getMaximumTerms

        public int getMaximumTerms()
      • getIndentResponse

        public int getIndentResponse()
      • allowOverrideMaximumRecords

        public boolean allowOverrideMaximumRecords()
      • allowOverrideMaximumTerms

        public boolean allowOverrideMaximumTerms()
      • allowOverrideIndentResponse

        public boolean allowOverrideIndentResponse()
      • getResponseBufferSize

        public int getResponseBufferSize()
      • getRecordSchemaIdentifier

        public String getRecordSchemaIdentifier​(String recordSchemaName)
      • getRecordSchemaName

        public String getRecordSchemaName​(String schemaIdentifier)
      • parse

        public static SRUServerConfig parse​(Map<String,​String> params,
                                            URL configFile)
                                     throws SRUConfigException
        Parse a SRU server XML configuration file and create an configuration object from it.
        Parameters:
        params - additional settings
        configFile - an URL pointing to the XML configuration file
        Returns:
        a initialized SRUEndpointConfig instance
        Throws:
        NullPointerException - if params or configFile is null
        SRUConfigException - if an error occurred