Changeset 6816
- Timestamp:
- 11/17/15 12:28:02 (9 years ago)
- Location:
- SRUServer/trunk/src/main/java/eu/clarin/sru/server
- Files:
-
- 2 added
- 9 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUConstants.java
r5924 r6816 155 155 public static final String SRU_RECORD_TOO_LARGE_TO_SEND = 156 156 SRU_DIAGNOSTIC_URI_PREFIX + 70; 157 public static final String SRU_UNSUPPORTED_ RECORD_PACKING=157 public static final String SRU_UNSUPPORTED_XML_ESCAPING_VALUE = 158 158 SRU_DIAGNOSTIC_URI_PREFIX + 71; 159 159 public static final String SRU_XPATH_RETRIEVAL_UNSUPPORTED = -
SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUDiagnostic.java
r5924 r6816 257 257 } else if (uri.equals(SRUConstants.SRU_RECORD_TOO_LARGE_TO_SEND)) { 258 258 return "Record too large to send"; 259 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_ RECORD_PACKING)) {259 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_XML_ESCAPING_VALUE)) { 260 260 return "Unsupported record packing"; 261 261 } else if (uri.equals(SRUConstants.SRU_XPATH_RETRIEVAL_UNSUPPORTED)) { -
SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRURecordPacking.java
r2623 r6816 18 18 19 19 /** 20 * SRU Record packing20 * SRU 2.0 record packing. 21 21 */ 22 22 public enum SRURecordPacking { 23 23 /** 24 * XML record packing 24 * The client requests that the server should supply records strictly 25 * according to the requested schema. 25 26 */ 26 XML,27 PACKED, 27 28 28 29 /** 29 * String record packing 30 * The server is free to allow the location of application data to vary 31 * within the record. 30 32 */ 31 STRING33 UNPACKED 32 34 } // enum SRURecordPacking -
SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRURecordXmlEscaping.java
r6107 r6816 18 18 19 19 /** 20 * SRU Record packing20 * SRU Record XML escaping. 21 21 */ 22 public enum SRURecord Packing {22 public enum SRURecordXmlEscaping { 23 23 /** 24 24 * XML record packing … … 30 30 */ 31 31 STRING 32 } // enum SRURecord Packing32 } // enum SRURecordXmlEscaping -
SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRURequest.java
r2866 r6816 81 81 82 82 /** 83 * Get the <em>recordPacking</em> parameter of this request. Only available 84 * for <em>explain</em> and <em>searchRetrieve</em> requests. 83 * Get the <em>recordXmlEscpaing</em> (SRU 2.0) or <em>recordPacking</em> 84 * (SRU 1.1 and SRU 1.2) parameter of this request. Only available for 85 * <em>explain</em> and <em>searchRetrieve</em> requests. 86 * 87 * @return the record XML escaping method 88 * @see SRURecordXmlEscaping 89 */ 90 public SRURecordXmlEscaping getRecordXmlEscaping(); 91 92 93 /** 94 * Get the <em>recordPacking</em> (SRU 2.0) parameter of this request. Only 95 * available for <em>searchRetrieve</em> requests. 85 96 * 86 97 * @return the record packing method … … 88 99 */ 89 100 public SRURecordPacking getRecordPacking(); 90 91 101 92 102 /** … … 118 128 */ 119 129 public int getMaximumRecords(); 120 121 122 /**123 * Get the <em>recordSchema</em> parameter of this request. Only available124 * for <em>searchRetrieve</em> requests.125 *126 * @return the record schema name or <code>null</code> if no value was127 * supplied for this request128 * @deprecated use {@link #getRecordSchemaIdentifier()}129 */130 @Deprecated131 public String getRecordSchemaName();132 130 133 131 … … 212 210 */ 213 211 public String getStylesheet(); 212 213 214 /** 215 * Get the <em>renderBy</em> parameter of this request. 216 * 217 * @return the renderBy parameter or <code>null</code> if no value was 218 * supplied for this request 219 */ 220 public SRURenderBy getRenderBy(); 221 222 223 /** 224 * (SRU 2.0) The request parameter <em>responseType</em>, paired with the 225 * Internet media type specified for the response (via either the httpAccept 226 * parameter or http accept header) determines the schema for the response. 227 * 228 * @return the value of the responeType request parameter or 229 * <code>null</code> if no value was supplied for this request 230 */ 231 public String getResponeType(); 232 233 234 /** 235 * (SRU 2.0) The request parameter <em>httpAccept</em> may be supplied to 236 * indicate the preferred format of the response. The value is an Internet 237 * media type. 238 * 239 * @return the value of the httpAccept request parameter or 240 * <code>null</code> if no value was supplied for 241 */ 242 public String getHttpAccept(); 214 243 215 244 -
SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRURequestImpl.java
r6787 r6816 35 35 private static final Logger logger = 36 36 LoggerFactory.getLogger(SRURequest.class); 37 private static final String PARAM_OPERATION = "operation"; 38 private static final String PARAM_VERSION = "version"; 39 private static final String PARAM_RECORD_PACKING = "recordPacking"; 40 private static final String PARAM_STYLESHEET = "stylesheet"; 41 private static final String PARAM_QUERY = "query"; 42 private static final String PARAM_START_RECORD = "startRecord"; 43 private static final String PARAM_MAXIMUM_RECORDS = "maximumRecords"; 44 private static final String PARAM_RECORD_SCHEMA = "recordSchema"; 45 private static final String PARAM_RECORD_X_PATH = "recordXPath"; 46 private static final String PARAM_RESULT_SET_TTL = "resultSetTTL"; 47 private static final String PARAM_SORT_KEYS = "sortKeys"; 48 private static final String PARAM_SCAN_CLAUSE = "scanClause"; 49 private static final String PARAM_RESPONSE_POSITION = "responsePosition"; 50 private static final String PARAM_MAXIMUM_TERMS = "maximumTerms"; 51 private static final String OP_EXPLAIN = "explain"; 52 private static final String OP_SCAN = "scan"; 53 private static final String OP_SEARCH_RETRIEVE = "searchRetrieve"; 54 private static final String VERSION_1_1 = "1.1"; 55 private static final String VERSION_1_2 = "1.2"; 56 private static final String RECORD_PACKING_XML = "xml"; 57 private static final String RECORD_PACKING_STRING = "string"; 58 private static final String PARAM_EXTENSION_PREFIX = "x-"; 59 private static final String X_UNLIMITED_RESULTSET = "x-unlimited-resultset"; 60 private static final String X_UNLIMITED_TERMLIST = "x-unlimited-termlist"; 61 private static final String X_INDENT_RESPONSE = "x-indent-response"; 62 private static final int DEFAULT_START_RECORD = 1; 63 private static final int DEFAULT_RESPONSE_POSITION = 1; 37 /* general / explain related parameter names */ 38 private static final String PARAM_OPERATION = "operation"; 39 private static final String PARAM_VERSION = "version"; 40 private static final String PARAM_STYLESHEET = "stylesheet"; 41 private static final String PARAM_RENDER_BY = "renderedBy"; 42 private static final String PARAM_HTTP_ACCEPT = "httpAccept"; 43 private static final String PARAM_RESPONSE_TYPE = "responseType"; 44 /* searchRetrieve related parameter names */ 45 private static final String PARAM_QUERY = "query"; 46 private static final String PARAM_QUERY_TYPE = "queryType"; 47 private static final String PARAM_START_RECORD = "startRecord"; 48 private static final String PARAM_MAXIMUM_RECORDS = "maximumRecords"; 49 private static final String PARAM_RECORD_XML_ESCAPING = "recordXMLEscaping"; 50 private static final String PARAM_RECORD_PACKING = "recordPacking"; 51 private static final String PARAM_RECORD_SCHEMA = "recordSchema"; 52 private static final String PARAM_RECORD_X_PATH = "recordXPath"; 53 private static final String PARAM_RESULT_SET_TTL = "resultSetTTL"; 54 private static final String PARAM_SORT_KEYS = "sortKeys"; 55 /* scan related parameter names */ 56 private static final String PARAM_SCAN_CLAUSE = "scanClause"; 57 private static final String PARAM_RESPONSE_POSITION = "responsePosition"; 58 private static final String PARAM_MAXIMUM_TERMS = "maximumTerms"; 59 /* operations */ 60 private static final String OP_EXPLAIN = "explain"; 61 private static final String OP_SCAN = "scan"; 62 private static final String OP_SEARCH_RETRIEVE = "searchRetrieve"; 63 private static final String VERSION_1_1 = "1.1"; 64 private static final String VERSION_1_2 = "1.2"; 65 /* various parameter values */ 66 private static final String RECORD_XML_ESCAPING_XML = "xml"; 67 private static final String RECORD_XML_ESCPAING_STRING = "string"; 68 private static final String RECORD_PACKING_PACKED = "packed"; 69 private static final String RECORD_PACKING_UNPACKED = "unpacked"; 70 private static final String RENDER_BY_CLIENT = "client"; 71 private static final String RENDER_BY_SERVER = "server"; 72 private static final String PARAM_EXTENSION_PREFIX = "x-"; 73 private static final String X_UNLIMITED_RESULTSET = "x-unlimited-resultset"; 74 private static final String X_UNLIMITED_TERMLIST = "x-unlimited-termlist"; 75 private static final String X_INDENT_RESPONSE = "x-indent-response"; 76 private static final int DEFAULT_START_RECORD = 1; 77 private static final int DEFAULT_RESPONSE_POSITION = 1; 64 78 private final SRUServerConfig config; 65 79 private final HttpServletRequest request; … … 67 81 private SRUOperation operation; 68 82 private SRUVersion version; 83 private SRURecordXmlEscaping recordXmlEscaping; 69 84 private SRURecordPacking recordPacking; 70 85 private CQLNode query; 86 private String queryType; 71 87 private int startRecord = DEFAULT_START_RECORD; 72 88 private int maximumRecords = -1; 73 89 private String recordSchemaIdentifier; 74 90 private String stylesheet; 91 private SRURenderBy renderBy; 92 private String responseType; 93 private String httpAccept; 75 94 private String recordXPath; 76 95 private int resultSetTTL = -1; … … 81 100 82 101 private static enum Parameter { 83 RECORD_PACKING, 102 STYLESHEET, 103 RENDER_BY, 104 HTTP_ACCEPT, 105 RESPONSE_TYPE, 84 106 QUERY, 107 QUERY_TYPE, 85 108 START_RECORD, 86 109 MAXIMUM_RECORDS, 110 RECORD_XML_ESCAPING, 111 RECORD_PACKING, 87 112 RECORD_SCHEMA, 88 113 RECORD_XPATH, … … 92 117 RESPONSE_POSITION, 93 118 MAXIMUM_TERMS, 94 STYLESHEET95 119 } 96 120 … … 113 137 } 114 138 115 public String getName( ) {139 public String getName(SRUVersion version) { 116 140 switch (parameter) { 117 case RECORD_PACKING: 118 return PARAM_RECORD_PACKING; 141 case STYLESHEET: 142 return PARAM_STYLESHEET; 143 case RENDER_BY: 144 return PARAM_RENDER_BY; 145 case HTTP_ACCEPT: 146 return PARAM_HTTP_ACCEPT; 147 case RESPONSE_TYPE: 148 return PARAM_RESPONSE_TYPE; 119 149 case QUERY: 120 150 return PARAM_QUERY; 151 case QUERY_TYPE: 152 return PARAM_QUERY_TYPE; 121 153 case START_RECORD: 122 154 return PARAM_START_RECORD; 123 155 case MAXIMUM_RECORDS: 124 156 return PARAM_MAXIMUM_RECORDS; 157 case RECORD_XML_ESCAPING: 158 /* 159 * 'recordPacking' was renamed to 'recordXMLEscaping' in SRU 160 * 2.0. For library API treat 'recordPacking' parameter as 161 * 'recordPacking' for SRU 1.1 and SRU 1.2. 162 */ 163 if (version == SRUVersion.VERSION_2_0) { 164 return PARAM_RECORD_XML_ESCAPING; 165 } else { 166 return PARAM_RECORD_PACKING; 167 } 168 case RECORD_PACKING: 169 /* 170 * FIXME: make this better 171 */ 172 if (version == SRUVersion.VERSION_2_0) { 173 return PARAM_RECORD_PACKING; 174 } else { 175 throw new InternalError("should not happen"); 176 } 125 177 case RECORD_SCHEMA: 126 178 return PARAM_RECORD_SCHEMA; … … 137 189 case MAXIMUM_TERMS: 138 190 return PARAM_MAXIMUM_TERMS; 139 case STYLESHEET:140 return PARAM_STYLESHEET;141 191 default: 142 192 throw new InternalError(); … … 154 204 } // class ParameterInfo 155 205 156 private static final ParameterInfo[] PARAMS_EXPLAIN = { 206 private static final ParameterInfo[] PARAMETER_SET_EXPLAIN = { 207 new ParameterInfo(Parameter.STYLESHEET, false, 208 SRUVersion.VERSION_1_1, SRUVersion.VERSION_1_2), 209 new ParameterInfo(Parameter.RECORD_XML_ESCAPING, false, 210 SRUVersion.VERSION_1_1, SRUVersion.VERSION_1_2) 211 }; 212 private static final ParameterInfo[] PARAMETER_SET_SCAN = { 213 new ParameterInfo(Parameter.STYLESHEET, false, 214 SRUVersion.VERSION_1_1, SRUVersion.VERSION_2_0), 215 new ParameterInfo(Parameter.HTTP_ACCEPT, false, 216 SRUVersion.VERSION_2_0, SRUVersion.VERSION_2_0), 217 new ParameterInfo(Parameter.SCAN_CLAUSE, true, 218 SRUVersion.VERSION_1_1, SRUVersion.VERSION_2_0), 219 new ParameterInfo(Parameter.RESPONSE_POSITION, false, 220 SRUVersion.VERSION_1_1, SRUVersion.VERSION_2_0), 221 new ParameterInfo(Parameter.MAXIMUM_TERMS, false, 222 SRUVersion.VERSION_1_1, SRUVersion.VERSION_2_0) 223 }; 224 private static final ParameterInfo[] PARAMETER_SET_SEARCH_RETRIEVE = { 225 new ParameterInfo(Parameter.STYLESHEET, false, 226 SRUVersion.VERSION_1_1, SRUVersion.VERSION_1_2), 227 new ParameterInfo(Parameter.HTTP_ACCEPT, false, 228 SRUVersion.VERSION_2_0, SRUVersion.VERSION_2_0), 229 new ParameterInfo(Parameter.RENDER_BY, false, 230 SRUVersion.VERSION_2_0, SRUVersion.VERSION_2_0), 231 new ParameterInfo(Parameter.RESPONSE_TYPE, false, 232 SRUVersion.VERSION_2_0, SRUVersion.VERSION_2_0), 233 new ParameterInfo(Parameter.QUERY, true, 234 SRUVersion.VERSION_1_1, SRUVersion.VERSION_2_0), 235 new ParameterInfo(Parameter.QUERY_TYPE, true, 236 SRUVersion.VERSION_2_0, SRUVersion.VERSION_2_0), 237 new ParameterInfo(Parameter.START_RECORD, false, 238 SRUVersion.VERSION_1_1, SRUVersion.VERSION_2_0), 239 new ParameterInfo(Parameter.MAXIMUM_RECORDS, false, 240 SRUVersion.VERSION_1_1, SRUVersion.VERSION_2_0), 241 new ParameterInfo(Parameter.RECORD_XML_ESCAPING, false, 242 SRUVersion.VERSION_1_1, SRUVersion.VERSION_2_0), 157 243 new ParameterInfo(Parameter.RECORD_PACKING, false, 158 SRUVersion.VERSION_1_1, SRUVersion.VERSION_1_2), 159 new ParameterInfo(Parameter.STYLESHEET, false, 160 SRUVersion.VERSION_1_1, SRUVersion.VERSION_1_2) 161 }; 162 private static final ParameterInfo[] PARAMS_SCAN = { 163 new ParameterInfo(Parameter.SCAN_CLAUSE, true, 164 SRUVersion.VERSION_1_1, SRUVersion.VERSION_1_2), 165 new ParameterInfo(Parameter.RESPONSE_POSITION, false, 166 SRUVersion.VERSION_1_1, SRUVersion.VERSION_1_2), 167 new ParameterInfo(Parameter.MAXIMUM_TERMS, false, 168 SRUVersion.VERSION_1_1, SRUVersion.VERSION_1_2), 169 new ParameterInfo(Parameter.STYLESHEET, false, 170 SRUVersion.VERSION_1_1, SRUVersion.VERSION_1_2) 171 172 }; 173 private static final ParameterInfo[] PARAMS_SEARCH_RETRIEVE = { 174 new ParameterInfo(Parameter.QUERY, true, 175 SRUVersion.VERSION_1_1, SRUVersion.VERSION_1_2), 176 new ParameterInfo(Parameter.START_RECORD, false, 177 SRUVersion.VERSION_1_1, SRUVersion.VERSION_1_2), 178 new ParameterInfo(Parameter.MAXIMUM_RECORDS, false, 179 SRUVersion.VERSION_1_1, SRUVersion.VERSION_1_2), 180 new ParameterInfo(Parameter.RECORD_PACKING, false, 181 SRUVersion.VERSION_1_1, SRUVersion.VERSION_1_2), 244 SRUVersion.VERSION_2_0, SRUVersion.VERSION_2_0), 182 245 new ParameterInfo(Parameter.RECORD_SCHEMA, false, 183 SRUVersion.VERSION_1_1, SRUVersion.VERSION_1_2), 246 SRUVersion.VERSION_1_1, SRUVersion.VERSION_2_0), 247 new ParameterInfo(Parameter.RESULT_SET_TTL, false, 248 SRUVersion.VERSION_1_1, SRUVersion.VERSION_2_0), 184 249 new ParameterInfo(Parameter.RECORD_XPATH, false, 185 SRUVersion.VERSION_1_1, SRUVersion.VERSION_1_1),186 new ParameterInfo(Parameter.RESULT_SET_TTL, false,187 250 SRUVersion.VERSION_1_1, SRUVersion.VERSION_1_2), 188 251 new ParameterInfo(Parameter.SORT_KEYS, false, 189 SRUVersion.VERSION_1_1, SRUVersion.VERSION_1_1), 190 new ParameterInfo(Parameter.STYLESHEET, false, 191 SRUVersion.VERSION_1_1, SRUVersion.VERSION_1_2) 252 SRUVersion.VERSION_1_1, SRUVersion.VERSION_2_0), 192 253 }; 193 254 … … 340 401 if (diagnostics == null) { 341 402 // check mandatory/optional parameters for operation 342 ParameterInfo[] parameter s;403 ParameterInfo[] parameter_set; 343 404 switch (operation) { 344 405 case EXPLAIN: 345 parameter s = PARAMS_EXPLAIN;406 parameter_set = PARAMETER_SET_EXPLAIN; 346 407 break; 347 408 case SCAN: 348 parameter s = PARAMS_SCAN;409 parameter_set = PARAMETER_SET_SCAN; 349 410 break; 350 411 case SEARCH_RETRIEVE: 351 parameter s = PARAMS_SEARCH_RETRIEVE;412 parameter_set = PARAMETER_SET_SEARCH_RETRIEVE; 352 413 break; 353 414 default: … … 366 427 367 428 // check parameters ... 368 for (ParameterInfo parameter : parameters) { 369 String value = getParameter(parameter.getName(), true, true); 429 for (ParameterInfo parameter : parameter_set) { 430 final String name = parameter.getName(version); 431 final String value = getParameter(name, true, true); 370 432 if (value != null) { 371 433 // remove supported parameter from list 372 parameterNames.remove( parameter.getName());434 parameterNames.remove(name); 373 435 374 436 /* … … 378 440 if (!parameter.isForVersion(version)) { 379 441 addDiagnostic(SRUConstants.SRU_UNSUPPORTED_PARAMETER, 380 parameter.getName(),442 name, 381 443 "Version " + version.getVersionString() + 382 444 " does not support parameter \"" + 383 parameter.getName()+ "\".");445 name + "\"."); 384 446 continue; 385 447 } … … 387 449 // validate and parse parameters ... 388 450 switch (parameter.getParameter()) { 389 case RECORD_ PACKING:390 if (value.e ndsWith(RECORD_PACKING_XML)) {391 record Packing = SRURecordPacking.XML;392 } else if (value.equals(RECORD_ PACKING_STRING)) {393 record Packing = SRURecordPacking.STRING;451 case RECORD_XML_ESCAPING: 452 if (value.equals(RECORD_XML_ESCAPING_XML)) { 453 recordXmlEscaping = SRURecordXmlEscaping.XML; 454 } else if (value.equals(RECORD_XML_ESCPAING_STRING)) { 455 recordXmlEscaping = SRURecordXmlEscaping.STRING; 394 456 } else { 395 457 addDiagnostic( 396 SRUConstants.SRU_UNSUPPORTED_RECORD_PACKING, 458 SRUConstants.SRU_UNSUPPORTED_XML_ESCAPING_VALUE, 459 null, "Record XML escaping \"" + value + 460 "\" is not supported."); 461 } 462 break; 463 case RECORD_PACKING: 464 if (value.equals(RECORD_PACKING_PACKED)) { 465 recordPacking = SRURecordPacking.PACKED; 466 } else if (value.equals(RECORD_PACKING_UNPACKED)) { 467 recordPacking = SRURecordPacking.UNPACKED; 468 } else { 469 addDiagnostic( 470 SRUConstants.SRU_UNSUPPORTED_PARAMETER_VALUE, 397 471 null, "Record packing \"" + value + 398 472 "\" is not supported."); … … 400 474 break; 401 475 case QUERY: 402 query = parseCQLParameter(parameter.getName(), value); 476 query = parseCQLParameter(name, value); 477 break; 478 case QUERY_TYPE: 479 queryType = parseQueryTypeParameter(name, value); 403 480 break; 404 481 case START_RECORD: 405 startRecord = parseNumberedParameter( 406 parameter.getName(), value, 1); 482 startRecord = parseNumberedParameter(name, value, 1); 407 483 break; 408 484 case MAXIMUM_RECORDS: 409 maximumRecords = parseNumberedParameter( 410 parameter.getName(), value, 0); 485 maximumRecords = parseNumberedParameter(name, value, 0); 411 486 break; 412 487 case RECORD_SCHEMA: … … 436 511 break; 437 512 case RESULT_SET_TTL: 438 resultSetTTL = parseNumberedParameter( 439 parameter.getName(), value, 0); 513 resultSetTTL = parseNumberedParameter(name, value, 0); 440 514 break; 441 515 case SORT_KEYS: … … 443 517 break; 444 518 case SCAN_CLAUSE: 445 scanClause = parseCQLParameter( 446 parameter.getName(), value); 519 scanClause = parseCQLParameter(name, value); 447 520 break; 448 521 case RESPONSE_POSITION: 449 522 responsePosition = parseNumberedParameter( 450 parameter.getName(), value, 0);523 name, value, 0); 451 524 break; 452 525 case MAXIMUM_TERMS: 453 maximumTerms = parseNumberedParameter( 454 parameter.getName(), value, 0); 526 maximumTerms = parseNumberedParameter(name, value, 0); 455 527 break; 456 528 case STYLESHEET: 457 529 stylesheet = value; 530 break; 531 case RENDER_BY: 532 if (value.equals(RENDER_BY_CLIENT)) { 533 renderBy = SRURenderBy.CLIENT; 534 } else if (value.equals(RENDER_BY_SERVER)) { 535 renderBy = SRURenderBy.SERVER; 536 } else { 537 addDiagnostic( 538 SRUConstants.SRU_UNSUPPORTED_PARAMETER_VALUE, 539 null, 540 "Value \"" + value + "\" for parameter '" + 541 name + "' is not supported."); 542 } 543 break; 544 case RESPONSE_TYPE: 545 /* 546 * FIXME: check parameter validity?! 547 */ 548 responseType = value; 549 break; 550 case HTTP_ACCEPT: 551 /* 552 * FIXME: check parameter validity?! 553 */ 554 httpAccept = value; 458 555 break; 459 556 } // switch … … 462 559 addDiagnostic( 463 560 SRUConstants.SRU_MANDATORY_PARAMETER_NOT_SUPPLIED, 464 parameter.getName(), "Mandatory parameter \"" + 465 parameter.getName() + 561 name, "Mandatory parameter \"" + name + 466 562 "\" was not supplied."); 467 563 } … … 503 599 504 600 505 SRURecord Packing getRawRecordPacking() {506 return record Packing;601 SRURecordXmlEscaping getRawRecordPacking() { 602 return recordXmlEscaping; 507 603 } 508 604 … … 585 681 586 682 @Override 683 public SRURecordXmlEscaping getRecordXmlEscaping() { 684 return (recordXmlEscaping != null) 685 ? recordXmlEscaping 686 : config.getDefaultRecordXmlEscaping(); 687 } 688 689 690 @Override 587 691 public SRURecordPacking getRecordPacking() { 588 692 return (recordPacking != null) … … 623 727 624 728 @Override 625 @Deprecated626 public String getRecordSchemaName() {627 return getRawRecordSchemaIdentifier();628 }629 630 631 @Override632 729 public String getRecordSchemaIdentifier() { 633 730 return recordSchemaIdentifier; … … 686 783 public String getStylesheet() { 687 784 return stylesheet; 785 } 786 787 788 @Override 789 public SRURenderBy getRenderBy() { 790 return renderBy; 791 } 792 793 794 @Override 795 public String getResponeType() { 796 return responseType; 797 } 798 799 800 @Override 801 public String getHttpAccept() { 802 if (httpAccept != null) { 803 return httpAccept; 804 } else { 805 return request.getHeader("ACCEPT"); 806 } 688 807 } 689 808 … … 808 927 return config.getDefaultVersion(); 809 928 } 929 } 930 931 932 private String parseQueryTypeParameter(String param, String value) { 933 if (value != null) { 934 for (int i = 0; i < value.length(); i++) { 935 final char ch = value.charAt(i); 936 if (!((ch >= 'a' && ch <= 'z') || 937 (ch >= 'A' && ch <= 'Z') || 938 (ch >= '0' && ch <= '9') || 939 ((i > 0) && ((ch == '-') || ch == '_')))) { 940 addDiagnostic(SRUConstants.SRU_UNSUPPORTED_PARAMETER_VALUE, 941 param, "Value contains illegal characters."); 942 } 943 } 944 } 945 return value; 810 946 } 811 947 -
SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUSearchResultSet.java
r2699 r6816 90 90 91 91 /** 92 * The idle time for this result. The default implementation returns 93 * <code>-1</code>. 94 * 95 * @return the result set idle time or <code>-1</code> if not applicable for 92 * The result set time to live. In SRU 2.0 it will be serialized as 93 * <code><resultSetTTL></code> element; in SRU 1.2 as 94 * <code><resultSetIdleTime></code> element.The default implementation 95 * returns <code>-1</code>. 96 * 97 * @return the result set time to live or <code>-1</code> if not applicable for 96 98 * this result 97 99 */ 98 public int getResultSet IdleTime() {100 public int getResultSetTTL() { 99 101 return -1; 102 } 103 104 105 /** 106 * (SRU 2.0) Indicate the accuracy of the result count reported by total 107 * number of records that matched the query. Default implementation returns 108 * <code>null</code>. 109 * 110 * @see SRUResultCountPrecision 111 * @return the result count precision or <code>null</code> if not applicable 112 * for this result 113 */ 114 public SRUResultCountPrecision getResultCountPrecision() { 115 return null; 100 116 } 101 117 -
SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUServer.java
r6787 r6816 123 123 SRUXMLStreamWriter out = 124 124 createXMLStreamWriter(response.getOutputStream(), 125 SRURecord Packing.XML, false,125 SRURecordXmlEscaping.XML, false, 126 126 req.getIndentResponse()); 127 127 final SRUNamespaces ns = getNamespaces(req.getVersion()); … … 164 164 SRUXMLStreamWriter out = 165 165 createXMLStreamWriter(response.getOutputStream(), 166 SRURecord Packing.XML, false,166 SRURecordXmlEscaping.XML, false, 167 167 req.getIndentResponse()); 168 168 final SRUNamespaces ns = getNamespaces(req.getVersion()); … … 201 201 SRUXMLStreamWriter out = 202 202 createXMLStreamWriter(response.getOutputStream(), 203 request.getRecord Packing(),203 request.getRecordXmlEscaping(), 204 204 true, 205 205 request.getIndentResponse()); … … 258 258 SRUXMLStreamWriter out = 259 259 createXMLStreamWriter(response.getOutputStream(), 260 request.getRecord Packing(),260 request.getRecordXmlEscaping(), 261 261 true, 262 262 request.getIndentResponse()); … … 394 394 SRUXMLStreamWriter out = 395 395 createXMLStreamWriter(response.getOutputStream(), 396 request.getRecord Packing(),396 request.getRecordXmlEscaping(), 397 397 true, 398 398 request.getIndentResponse()); … … 413 413 } 414 414 415 // resultSetIdleTime 416 if (result.getResultSetIdleTime() > 0) { 415 // resultSetIdleTime (SRU 1.1 and SRU 1.2) 416 if (!request.isVersion(SRUVersion.VERSION_2_0) && 417 (result.getResultSetTTL() > 0)) { 417 418 out.writeStartElement(ns.getResponseNS(), "resultSetIdleTime"); 418 419 out.writeCharacters(Integer.toString(result 419 .getResultSet IdleTime()));420 .getResultSetTTL())); 420 421 out.writeEndElement(); // "resultSetIdleTime" element 421 422 } … … 465 466 466 467 // recordPacking 467 writeRecordPacking(out, ns, request.getRecord Packing());468 writeRecordPacking(out, ns, request.getRecordXmlEscaping()); 468 469 469 470 /* … … 482 483 483 484 /* 484 * recordIdentifier is version 1.2 only485 * recordIdentifier is version 1.2+ only 485 486 */ 486 if (request.isVersion(SRUVersion.VERSION_1_2)) { 487 if (request.isVersion(SRUVersion.VERSION_1_2, 488 SRUVersion.VERSION_2_0)) { 487 489 final String identifier = 488 490 result.getRecordIdentifier(); … … 543 545 } 544 546 547 // SRU 2.0 stuff ... 548 if (request.isVersion(SRUVersion.VERSION_2_0)) { 549 // resultSetTTL 550 if (result.getResultSetTTL() > 0) { 551 out.writeStartElement(ns.getResponseNS(), "resultSetTTL"); 552 out.writeCharacters(Integer.toString(result 553 .getResultSetTTL())); 554 out.writeEndElement(); // "resultSetTTL" element 555 } 556 557 // resultCountPrecision (SRU 2.0) 558 final SRUResultCountPrecision precision = 559 result.getResultCountPrecision(); 560 if (precision != null) { 561 out.writeStartElement(ns.getResponseNS(), "resultCountPrecision"); 562 switch (precision) { 563 case EXACT: 564 out.writeCharacters("info:srw/vocabulary/resultCountPrecision/1/exact"); 565 break; 566 case UNKNOWN: 567 out.writeCharacters("info:srw/vocabulary/resultCountPrecision/1/unknown"); 568 break; 569 case ESTIMATE: 570 out.writeCharacters("info:srw/vocabulary/resultCountPrecision/1/estimate"); 571 break; 572 case MAXIMUM: 573 out.writeCharacters("info:srw/vocabulary/resultCountPrecision/1/maximum"); 574 break; 575 case MINIMUM: 576 out.writeCharacters("info:srw/vocabulary/resultCountPrecision/1/minimum"); 577 break; 578 case CURRENT: 579 out.writeCharacters("info:srw/vocabulary/resultCountPrecision/1/current"); 580 break; 581 } // switch 582 out.writeEndElement(); // "resultCountPrecision" element 583 } 584 585 // facetedResults 586 // NOT YET SUPPORTED 587 588 // searchResultAnalysis 589 // NOT YET SUPPORTED 590 } 545 591 endResponse(out); 546 592 } finally { … … 666 712 667 713 // recordPacking 668 writeRecordPacking(out, ns, request.getRecord Packing());714 writeRecordPacking(out, ns, request.getRecordXmlEscaping()); 669 715 670 716 out.writeStartElement(ns.getResponseNS(), "recordData"); … … 1025 1071 } 1026 1072 1073 // echoedSearchRetrieveRequest/renderedBy 1074 // FIXME: NOT YET IMPLEMENTED 1075 1076 // echoedSearchRetrieveRequest/extraRequestParameter 1077 // FIXME: NOT YET IMPLEMENTED 1078 1079 // echoedSearchRetrieveRequest/httpAccept 1080 // FIXME: NOT YET IMPLEMENTED 1081 1082 // echoedSearchRetrieveRequest/responseType 1083 // FIXME: NOT YET IMPLEMENTED 1084 1027 1085 // echoedSearchRetrieveRequest/baseUrl (SRU 1.2 only) 1028 1086 if (request.isVersion(SRUVersion.VERSION_1_2)) { … … 1053 1111 1054 1112 private void writeRecordPacking(SRUXMLStreamWriter out, SRUNamespaces ns, 1055 SRURecord Packing recordPacking) throws XMLStreamException {1113 SRURecordXmlEscaping recordPacking) throws XMLStreamException { 1056 1114 out.writeStartElement(ns.getResponseNS(), "recordPacking"); 1057 1115 switch (recordPacking) { … … 1096 1154 1097 1155 private SRUXMLStreamWriter createXMLStreamWriter(OutputStream out, 1098 SRURecord Packing recordPacking, boolean skipFlush, int indent)1156 SRURecordXmlEscaping recordPacking, boolean skipFlush, int indent) 1099 1157 throws SRUException { 1100 1158 try { -
SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUServerConfig.java
r6787 r6816 717 717 718 718 719 public SRURecordXmlEscaping getDefaultRecordXmlEscaping() { 720 return SRURecordXmlEscaping.XML; 721 } 722 723 719 724 public SRURecordPacking getDefaultRecordPacking() { 720 return SRURecordPacking. XML;725 return SRURecordPacking.PACKED; 721 726 } 722 727 -
SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUXMLStreamWriter.java
r2729 r6816 45 45 } 46 46 private static final SAXParserFactory factory; 47 private final SRURecord Packing packing;47 private final SRURecordXmlEscaping recordEscaping; 48 48 private final Writer writer; 49 49 private final XMLStreamWriter xmlwriter; … … 55 55 56 56 57 SRUXMLStreamWriter(OutputStream stream, XMLOutputFactory factory, 58 SRURecordPacking recordPacking, int indent) throws IOException, 59 XMLStreamException { 60 this.packing = recordPacking; 57 SRUXMLStreamWriter(OutputStream stream, 58 XMLOutputFactory factory, 59 SRURecordXmlEscaping recordXmlEscaping, 60 int indent) throws IOException, XMLStreamException { 61 this.recordEscaping = recordXmlEscaping; 61 62 this.writer = new OutputStreamWriter(stream, 62 63 SRUServer.RESPONSE_ENCODING) { 63 64 @Override 64 65 public void write(int c) throws IOException { 65 if (writingRecord && ( packing == SRURecordPacking.STRING)) {66 if (writingRecord && (recordEscaping == SRURecordXmlEscaping.STRING)) { 66 67 /* 67 68 * NOTE: need to write single characters here, because … … 98 99 @Override 99 100 public void write(char[] c, int off, int len) throws IOException { 100 if (writingRecord && ( packing == SRURecordPacking.STRING)) {101 if (writingRecord && (recordEscaping == SRURecordXmlEscaping.STRING)) { 101 102 for (int i = off; i < len; i++) { 102 103 this.write(c[i]); … … 109 110 @Override 110 111 public void write(String s, int off, int len) throws IOException { 111 if (writingRecord && ( packing == SRURecordPacking.STRING)) {112 if (writingRecord && (recordEscaping == SRURecordXmlEscaping.STRING)) { 112 113 for (int i = off; i < len; i++) { 113 114 this.write(s.charAt(i)); … … 480 481 481 482 private void onStartElement() throws XMLStreamException { 482 if (!(writingRecord && ( packing == SRURecordPacking.STRING))) {483 if (!(writingRecord && (recordEscaping == SRURecordXmlEscaping.STRING))) { 483 484 stateStack.push(IndentingState.SEEN_ELEMENT); 484 485 state = IndentingState.SEEN_NOTHING; … … 493 494 494 495 private void onEndElement() throws XMLStreamException { 495 if (!(writingRecord && ( packing == SRURecordPacking.STRING))) {496 if (!(writingRecord && (recordEscaping == SRURecordXmlEscaping.STRING))) { 496 497 depth--; 497 498 if (state == IndentingState.SEEN_ELEMENT) { … … 505 506 506 507 private void onEmptyElement() throws XMLStreamException { 507 if (!(writingRecord && ( packing == SRURecordPacking.STRING))) {508 if (!(writingRecord && (recordEscaping == SRURecordXmlEscaping.STRING))) { 508 509 state = IndentingState.SEEN_ELEMENT; 509 510 if (depth > 0) {
Note: See TracChangeset
for help on using the changeset viewer.