Changeset 2163
- Timestamp:
- 08/28/12 19:56:00 (12 years ago)
- 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 22 22 23 23 24 25 /** 26 * Abstract base class for SRU requests. 27 * 28 * @see SRUExplainResponse 29 * @see SRUScanResponse 30 * @see SRUSearchRetrieveResponse 31 */ 24 32 abstract class SRUAbstractRequest { 25 33 static final String PARAM_OPERATION = "operation"; … … 113 121 114 122 123 /** 124 * Constructor. 125 * 126 * @param endpointURI 127 * the URI of the endpoint 128 * @throws NullPointerException 129 * if any required argument is null 130 */ 115 131 protected SRUAbstractRequest(String endpointURI) { 116 132 if (endpointURI == null) { … … 124 140 * Get the endpoint URI. 125 141 * 126 * @return the endpoi unt URI142 * @return the endpoint URI 127 143 */ 128 144 public String getEndpointURI() { -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUClient.java
r2157 r2163 45 45 import org.slf4j.LoggerFactory; 46 46 47 import eu.clarin.sru.client.SRUScanHandler.WhereInList;48 47 49 48 /** … … 650 649 String s = reader.readContent(SRU_NS, 651 650 "whereInList", false); 652 WhereInList whereInList = null;651 SRUWhereInList whereInList = null; 653 652 if (s != null) { 654 653 if ("first".equals(s)) { 655 whereInList = WhereInList.FIRST;654 whereInList = SRUWhereInList.FIRST; 656 655 } else if ("last".equals(s)) { 657 whereInList = WhereInList.LAST;656 whereInList = SRUWhereInList.LAST; 658 657 } else if ("only".equals(s)) { 659 whereInList = WhereInList.ONLY;658 whereInList = SRUWhereInList.ONLY; 660 659 } else if ("inner".equals(s)) { 661 whereInList = WhereInList.INNER;660 whereInList = SRUWhereInList.INNER; 662 661 } else { 663 662 throw new SRUClientException( … … 869 868 } 870 869 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."); 875 880 } 876 881 } 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."); 880 893 } 881 894 } … … 946 959 if (strictMode) { 947 960 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)"); 949 965 } 950 966 } else { … … 953 969 " record(s)"); 954 970 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)"); 957 976 } 958 977 } … … 972 991 973 992 /* 974 * common error: echoedSearchRetrieveRequest in default namespace 993 * common error: echoedSearchRetrieveRequest in 994 * default namespace 975 995 */ 976 996 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"); 978 1000 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"); 980 1005 } 981 1006 reader.readEnd("", "echoedSearchRetrieveRequest", true); … … 1074 1099 1075 1100 private static SRURecordPacking parseRecordPacking( 1076 SRUXMLStreamReader reader, boolean pedantic)1101 SRUXMLStreamReader reader, boolean strictMode) 1077 1102 throws XMLStreamException, SRUClientException { 1078 1103 final String v = reader.readContent(SRU_NS, "recordPacking", true); … … 1082 1107 } else if (RECORD_PACKING_STRING.equals(v)) { 1083 1108 return SRURecordPacking.STRING; 1084 } else if (! pedantic&& RECORD_PACKING_XML.equalsIgnoreCase(v)) {1109 } else if (!strictMode && RECORD_PACKING_XML.equalsIgnoreCase(v)) { 1085 1110 logger.error("invalid value '{}' for record packing, should be '{}'", 1086 1111 v, RECORD_PACKING_XML); 1087 1112 return SRURecordPacking.XML; 1088 } else if (! pedantic&& RECORD_PACKING_STRING.equalsIgnoreCase(v)) {1113 } else if (!strictMode && RECORD_PACKING_STRING.equalsIgnoreCase(v)) { 1089 1114 logger.error("invalid value '{}' for record packing, should be '{}'", 1090 1115 v, RECORD_PACKING_STRING); -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUDefaultHandlerAdapter.java
r2156 r2163 76 76 @Override 77 77 public void onTerm(String value, int numberOfRecords, String displayTerm, 78 WhereInList whereInList) throws SRUClientException {78 SRUWhereInList whereInList) throws SRUClientException { 79 79 } 80 80 -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRURecordPacking.java
r2088 r2163 18 18 19 19 /** 20 * SRU Record packing20 * SRU record packing 21 21 */ 22 22 public enum SRURecordPacking { -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUScanHandler.java
r2088 r2163 31 31 */ 32 32 public interface SRUScanHandler { 33 /**34 * A flag to indicate the position of the term within the complete term35 * 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 60 33 /** 61 34 * Receive notification of diagnostics. … … 141 114 */ 142 115 public void onTerm(String value, int numberOfRecords, String displayTerm, 143 WhereInList whereInList) throws SRUClientException;116 SRUWhereInList whereInList) throws SRUClientException; 144 117 145 118 -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUVersion.java
r2088 r2163 13 13 * SRU/CQL version 1.2 14 14 */ 15 VERSION_1_2; 15 VERSION_1_2 16 16 17 } // enum SRUVersion -
SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/ClarinFederatedContentSearchRecordData.java
r2088 r2163 26 26 public final class ClarinFederatedContentSearchRecordData implements 27 27 SRURecordData { 28 /** 29 * The record schema for CLARIN FCS records. 30 */ 31 public static final String RECORD_SCHEMA = "http://clarin.eu/fcs/1.0"; 28 32 private String pid; 29 33 private String left; -
SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/ClarinFederatedContentSearchRecordParser.java
r2088 r2163 36 36 private static final Logger logger = 37 37 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; 40 40 public static final String FCS_KWIC_NS = "http://clarin.eu/fcs/1.0/kwic"; 41 41 private static final String DATAVIEW_KWIC = "kwic"; … … 44 44 @Override 45 45 public String getRecordSchema() { 46 return FCS_RECORD_SCHEMA;46 return ClarinFederatedContentSearchRecordData.RECORD_SCHEMA; 47 47 } 48 48 -
SRUClient/trunk/src/test/java/eu/clarin/sru/client/TestClient.java
r2156 r2163 77 77 @Override 78 78 public void onTerm(String value, int numberOfRecords, 79 String displayTerm, WhereInList whereInList)79 String displayTerm, SRUWhereInList whereInList) 80 80 throws SRUClientException { 81 81 logger.info("onTerm(): value = {}, numberOfRecords = {}, displayTerm = {}, whereInList = {}", … … 152 152 new SRUSearchRetrieveRequest(args[0]); 153 153 request.setQuery("Faustus"); 154 request.setRecordSchema(ClarinFederatedContentSearchRecord Parser.FCS_RECORD_SCHEMA);154 request.setRecordSchema(ClarinFederatedContentSearchRecordData.RECORD_SCHEMA); 155 155 request.setMaximumRecords(5); 156 156 request.setRecordPacking(SRURecordPacking.XML);
Note: See TracChangeset
for help on using the changeset viewer.