Changeset 2163


Ignore:
Timestamp:
08/28/12 19:56:00 (12 years ago)
Author:
oschonef
Message:

OT: I saw tail lights last night in a dream about my first wife ...

Location:
SRUClient/trunk/src
Files:
2 added
9 edited

Legend:

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

    r2121 r2163  
    2222
    2323
     24
     25/**
     26 * Abstract base class for SRU requests.
     27 *
     28 * @see SRUExplainResponse
     29 * @see SRUScanResponse
     30 * @see SRUSearchRetrieveResponse
     31 */
    2432abstract class SRUAbstractRequest {
    2533    static final String PARAM_OPERATION                = "operation";
     
    113121
    114122
     123    /**
     124     * Constructor.
     125     *
     126     * @param endpointURI
     127     *            the URI of the endpoint
     128     * @throws NullPointerException
     129     *             if any required argument is null
     130     */
    115131    protected SRUAbstractRequest(String endpointURI) {
    116132        if (endpointURI == null) {
     
    124140     * Get the endpoint URI.
    125141     *
    126      * @return the endpoiunt URI
     142     * @return the endpoint URI
    127143     */
    128144    public String getEndpointURI() {
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUClient.java

    r2157 r2163  
    4545import org.slf4j.LoggerFactory;
    4646
    47 import eu.clarin.sru.client.SRUScanHandler.WhereInList;
    4847
    4948/**
     
    650649                        String s = reader.readContent(SRU_NS,
    651650                                "whereInList", false);
    652                         WhereInList whereInList = null;
     651                        SRUWhereInList whereInList = null;
    653652                        if (s != null) {
    654653                            if ("first".equals(s)) {
    655                                 whereInList = WhereInList.FIRST;
     654                                whereInList = SRUWhereInList.FIRST;
    656655                            } else if ("last".equals(s)) {
    657                                 whereInList = WhereInList.LAST;
     656                                whereInList = SRUWhereInList.LAST;
    658657                            } else if ("only".equals(s)) {
    659                                 whereInList = WhereInList.ONLY;
     658                                whereInList = SRUWhereInList.ONLY;
    660659                            } else if ("inner".equals(s)) {
    661                                 whereInList = WhereInList.INNER;
     660                                whereInList = SRUWhereInList.INNER;
    662661                            } else {
    663662                                throw new SRUClientException(
     
    869868                                }
    870869                                if (recordData == null) {
    871                                     // FIXME: handle this better? maybe throw?
    872                                     logger.warn("parse did not correctly "
    873                                             + "parse the record, will skip "
    874                                             + "handler callback.");
     870                                    logger.debug("parser did not parse " +
     871                                            "record correctly and returned " +
     872                                            "null.");
     873                                    surrogate = new SRUDiagnostic(
     874                                            SRUClientDiagnostics.DIAG_RECORD_PARSER_NULL,
     875                                            null, "Record parser for schema '" +
     876                                                    schema + "' did nor " +
     877                                                    "parse record correctly " +
     878                                                    "and errornously " +
     879                                                    "returned null.");
    875880                                }
    876881                            } else {
    877                                 // FIXME: handle this better?
    878                                 logger.debug("no record parser found for schema '{}'",
    879                                         schema);
     882                                /*
     883                                 * no record parser found, inject a
     884                                 * surrogate diagnostic
     885                                 */
     886                                logger.debug("no record data parser found " +
     887                                        "for schema '{}'", schema);
     888                                surrogate = new SRUDiagnostic(
     889                                        SRUClientDiagnostics.DIAG_NO_RECORD_PARSER,
     890                                        schema,
     891                                        "No record data parser for schema '" +
     892                                                schema + "' found.");
    880893                            }
    881894                        }
     
    946959                            if (strictMode) {
    947960                                throw new SRUClientException(
    948                                         "endpoint declared 0 results, but response contained an empty 'records' element (behavior violates SRU specification)");
     961                                        "endpoint declared 0 results, but " +
     962                                        "response contained an empty " +
     963                                        "'records' element (behavior " +
     964                                        "violates SRU specification)");
    949965                            }
    950966                        } else {
     
    953969                                    " record(s)");
    954970                            if (strictMode) {
    955                             throw new SRUClientException("endpoint declared 0 results, but response containted " +
    956                                     bad + " records (behavior may violate SRU specification)");
     971                                throw new SRUClientException(
     972                                            "endpoint declared 0 results, " +
     973                                            "but response containted " + bad +
     974                                            " records (behavior may violate " +
     975                                            "SRU specification)");
    957976                            }
    958977                        }
     
    972991
    973992                /*
    974                  * common error: echoedSearchRetrieveRequest in default namespace
     993                 * common error: echoedSearchRetrieveRequest in
     994                 * default namespace
    975995                 */
    976996                if (reader.readStart("", "echoedSearchRetrieveRequest", false)) {
    977                     logger.error("Element 'echoedSearchRetrieveRequest' must be in SRU namespace, but endpoint put it into default namespace");
     997                    logger.error("Element 'echoedSearchRetrieveRequest' " +
     998                            "must be in SRU namespace, but endpoint put it " +
     999                            "into default namespace");
    9781000                    if (strictMode) {
    979                         throw new SRUClientException("Element 'echoedSearchRetrieveRequest' must be in SRU namespace, but endpoint put it into default namespace");
     1001                        throw new SRUClientException(
     1002                                "Element 'echoedSearchRetrieveRequest' must " +
     1003                                "be in SRU namespace, but endpoint put it " +
     1004                                "into default namespace");
    9801005                    }
    9811006                    reader.readEnd("", "echoedSearchRetrieveRequest", true);
     
    10741099
    10751100    private static SRURecordPacking parseRecordPacking(
    1076             SRUXMLStreamReader reader, boolean pedantic)
     1101            SRUXMLStreamReader reader, boolean strictMode)
    10771102            throws XMLStreamException, SRUClientException {
    10781103        final String v = reader.readContent(SRU_NS, "recordPacking", true);
     
    10821107        } else if (RECORD_PACKING_STRING.equals(v)) {
    10831108            return SRURecordPacking.STRING;
    1084         } else if (!pedantic && RECORD_PACKING_XML.equalsIgnoreCase(v)) {
     1109        } else if (!strictMode && RECORD_PACKING_XML.equalsIgnoreCase(v)) {
    10851110            logger.error("invalid value '{}' for record packing, should be '{}'",
    10861111                         v, RECORD_PACKING_XML);
    10871112            return SRURecordPacking.XML;
    1088         } else if (!pedantic && RECORD_PACKING_STRING.equalsIgnoreCase(v)) {
     1113        } else if (!strictMode && RECORD_PACKING_STRING.equalsIgnoreCase(v)) {
    10891114            logger.error("invalid value '{}' for record packing, should be '{}'",
    10901115                         v, RECORD_PACKING_STRING);
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUDefaultHandlerAdapter.java

    r2156 r2163  
    7676    @Override
    7777    public void onTerm(String value, int numberOfRecords, String displayTerm,
    78             WhereInList whereInList) throws SRUClientException {
     78            SRUWhereInList whereInList) throws SRUClientException {
    7979    }
    8080
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRURecordPacking.java

    r2088 r2163  
    1818
    1919/**
    20  * SRU Record packing
     20 * SRU record packing
    2121 */
    2222public enum SRURecordPacking {
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUScanHandler.java

    r2088 r2163  
    3131 */
    3232public interface SRUScanHandler {
    33     /**
    34      * A flag to indicate the position of the term within the complete term
    35      * list.
    36      */
    37     public enum WhereInList {
    38         /**
    39          * The first term (<em>first</em>)
    40          */
    41         FIRST,
    42 
    43         /**
    44          * The last term (<em>last</em>)
    45          */
    46         LAST,
    47 
    48         /**
    49          * The only term (<em>only</em>)
    50          */
    51         ONLY,
    52 
    53         /**
    54          * Any other term (<em>inner</em>)
    55          */
    56         INNER;
    57     }
    58 
    59 
    6033    /**
    6134     * Receive notification of diagnostics.
     
    141114     */
    142115    public void onTerm(String value, int numberOfRecords, String displayTerm,
    143             WhereInList whereInList) throws SRUClientException;
     116            SRUWhereInList whereInList) throws SRUClientException;
    144117
    145118
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUVersion.java

    r2088 r2163  
    1313     * SRU/CQL version 1.2
    1414     */
    15     VERSION_1_2;
     15    VERSION_1_2
     16
    1617} // enum SRUVersion
  • SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/ClarinFederatedContentSearchRecordData.java

    r2088 r2163  
    2626public final class ClarinFederatedContentSearchRecordData implements
    2727        SRURecordData {
     28    /**
     29     * The record schema for CLARIN FCS records.
     30     */
     31    public static final String RECORD_SCHEMA = "http://clarin.eu/fcs/1.0";
    2832    private String pid;
    2933    private String left;
  • SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/ClarinFederatedContentSearchRecordParser.java

    r2088 r2163  
    3636    private static final Logger logger =
    3737            LoggerFactory.getLogger(ClarinFederatedContentSearchRecordParser.class);
    38     public static final String FCS_NS = "http://clarin.eu/fcs/1.0";
    39     public static final String FCS_RECORD_SCHEMA = FCS_NS;
     38    public static final String FCS_NS =
     39            ClarinFederatedContentSearchRecordData.RECORD_SCHEMA;
    4040    public static final String FCS_KWIC_NS = "http://clarin.eu/fcs/1.0/kwic";
    4141    private static final String DATAVIEW_KWIC = "kwic";
     
    4444    @Override
    4545    public String getRecordSchema() {
    46         return FCS_RECORD_SCHEMA;
     46        return ClarinFederatedContentSearchRecordData.RECORD_SCHEMA;
    4747    }
    4848
  • SRUClient/trunk/src/test/java/eu/clarin/sru/client/TestClient.java

    r2156 r2163  
    7777                @Override
    7878                public void onTerm(String value, int numberOfRecords,
    79                         String displayTerm, WhereInList whereInList)
     79                        String displayTerm, SRUWhereInList whereInList)
    8080                        throws SRUClientException {
    8181                    logger.info("onTerm(): value = {}, numberOfRecords = {}, displayTerm = {}, whereInList = {}",
     
    152152                        new SRUSearchRetrieveRequest(args[0]);
    153153                request.setQuery("Faustus");
    154                 request.setRecordSchema(ClarinFederatedContentSearchRecordParser.FCS_RECORD_SCHEMA);
     154                request.setRecordSchema(ClarinFederatedContentSearchRecordData.RECORD_SCHEMA);
    155155                request.setMaximumRecords(5);
    156156                request.setRecordPacking(SRURecordPacking.XML);
Note: See TracChangeset for help on using the changeset viewer.