- Timestamp:
- 01/16/15 11:04:06 (9 years ago)
- Location:
- SRUServer/trunk/src/main/java/eu/clarin/sru/server
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUAbstractResult.java
r2623 r5924 40 40 * Add a non surrogate diagnostic to the response. 41 41 * 42 * @param code43 * numerical diagnostic code42 * @param uri 43 * the diagnostic's identifying URI 44 44 * @param details 45 45 * supplementary information available, often in a format … … 49 49 * <code>null</code> 50 50 */ 51 protected final void addDiagnostic( int code, String details, String message) {52 diagnostics.addDiagnostic( code, details, message);51 protected final void addDiagnostic(String uri, String details, String message) { 52 diagnostics.addDiagnostic(uri, details, message); 53 53 } 54 54 … … 57 57 * Add a non surrogate diagnostic to the response. 58 58 * 59 * @param code60 * numerical diagnostic code59 * @param uri 60 * the diagnostic's identifying URI 61 61 * @param details 62 62 * supplementary information available, often in a format 63 63 * specified by the diagnostic or <code>null</code> 64 64 */ 65 protected final void addDiagnostic( int code, String details) {66 addDiagnostic( code, details, null);65 protected final void addDiagnostic(String uri, String details) { 66 addDiagnostic(uri, details, null); 67 67 } 68 68 … … 71 71 * Add a non surrogate diagnostic to the response. 72 72 * 73 * @param code74 * numerical diagnostic code73 * @param uri 74 * the diagnostic's identifying URI 75 75 */ 76 protected final void addDiagnostic( int code) {77 addDiagnostic( code, null, null);76 protected final void addDiagnostic(String uri) { 77 addDiagnostic(uri, null, null); 78 78 } 79 79 -
SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUConstants.java
r2623 r5924 27 27 */ 28 28 public final class SRUConstants { 29 // private constants 30 private static final String SRU_DIAGNOSTIC_URI_PREFIX = 31 "info:srw/diagnostic/1/"; 29 32 30 33 // general diagnostics 31 public static final int SRU_GENERAL_SYSTEM_ERROR = 1; 32 public static final int SRU_SYSTEM_TEMPORARILY_UNAVAILABLE = 2; 33 public static final int SRU_AUTHENTICATION_ERROR = 3; 34 public static final int SRU_UNSUPPORTED_OPERATION = 4; 35 public static final int SRU_UNSUPPORTED_VERSION = 5; 36 public static final int SRU_UNSUPPORTED_PARAMETER_VALUE = 6; 37 public static final int SRU_MANDATORY_PARAMETER_NOT_SUPPLIED = 7; 38 public static final int SRU_UNSUPPORTED_PARAMETER = 8; 34 public static final String SRU_GENERAL_SYSTEM_ERROR = 35 SRU_DIAGNOSTIC_URI_PREFIX + 1; 36 public static final String SRU_SYSTEM_TEMPORARILY_UNAVAILABLE = 37 SRU_DIAGNOSTIC_URI_PREFIX + 2; 38 public static final String SRU_AUTHENTICATION_ERROR = 39 SRU_DIAGNOSTIC_URI_PREFIX + 3; 40 public static final String SRU_UNSUPPORTED_OPERATION = 41 SRU_DIAGNOSTIC_URI_PREFIX + 4; 42 public static final String SRU_UNSUPPORTED_VERSION = 43 SRU_DIAGNOSTIC_URI_PREFIX + 5; 44 public static final String SRU_UNSUPPORTED_PARAMETER_VALUE = 45 SRU_DIAGNOSTIC_URI_PREFIX + 6; 46 public static final String SRU_MANDATORY_PARAMETER_NOT_SUPPLIED = 47 SRU_DIAGNOSTIC_URI_PREFIX + 7; 48 public static final String SRU_UNSUPPORTED_PARAMETER = 49 SRU_DIAGNOSTIC_URI_PREFIX + 8; 39 50 // diagnostics relating to CQL 40 public static final int SRU_QUERY_SYNTAX_ERROR = 10; 41 public static final int SRU_TOO_MANY_CHARACTERS_IN_QUERY = 12; 42 public static final int SRU_INVALID_OR_UNSUPPORTED_USE_OF_PARENTHESES = 13; 43 public static final int SRU_INVALID_OR_UNSUPPORTED_USE_OF_QUOTES = 14; 44 public static final int SRU_UNSUPPORTED_CONTEXT_SET = 15; 45 public static final int SRU_UNSUPPORTED_INDEX = 16; 46 public static final int SRU_UNSUPPORTED_COMBINATION_OF_INDEXES = 18; 47 public static final int SRU_UNSUPPORTED_RELATION = 19; 48 public static final int SRU_UNSUPPORTED_RELATION_MODIFIER = 20; 49 public static final int SRU_UNSUPPORTED_COMBINATION_OF_RELATION_MODIFERS = 21; 50 public static final int SRU_UNSUPPORTED_COMBINATION_OF_RELATION_AND_INDEX = 22; 51 public static final int SRU_TOO_MANY_CHARACTERS_IN_TERM = 23; 52 public static final int SRU_UNSUPPORTED_COMBINATION_OF_RELATION_AND_TERM = 24; 53 public static final int SRU_NON_SPECIAL_CHARACTER_ESCAPED_IN_TERM = 26; 54 public static final int SRU_EMPTY_TERM_UNSUPPORTED = 27; 55 public static final int SRU_MASKING_CHARACTER_NOT_SUPPORTED = 28; 56 public static final int SRU_MASKED_WORDS_TOO_SHORT = 29; 57 public static final int SRU_TOO_MANY_MASKING_CHARACTERS_IN_TERM = 30; 58 public static final int SRU_ANCHORING_CHARACTER_NOT_SUPPORTED = 31; 59 public static final int SRU_ANCHORING_CHARACTER_IN_UNSUPPORTED_POSITION = 32; 60 public static final int SRU_COMBINATION_OF_PROXIMITY_ADJACENCY_AND_MASKING_CHARACTERS_NOT_SUPPORTED = 33; 61 public static final int SRU_COMBINATION_OF_PROXIMITY_ADJACENCY_AND_ANCHORING_CHARACTERS_NOT_SUPPORTED = 34; 62 public static final int SRU_TERM_CONTAINS_ONLY_STOPWORDS = 35; 63 public static final int SRU_TERM_IN_INVALID_FORMAT_FOR_INDEX_OR_RELATION = 36; 64 public static final int SRU_UNSUPPORTED_BOOLEAN_OPERATOR = 37; 65 public static final int SRU_TOO_MANY_BOOLEAN_OPERATORS_IN_QUERY = 38; 66 public static final int SRU_PROXIMITY_NOT_SUPPORTED = 39; 67 public static final int SRU_UNSUPPORTED_PROXIMITY_RELATION = 40; 68 public static final int SRU_UNSUPPORTED_PROXIMITY_DISTANCE = 41; 69 public static final int SRU_UNSUPPORTED_PROXIMITY_UNIT = 42; 70 public static final int SRU_UNSUPPORTED_PROXIMITY_ORDERING = 43; 71 public static final int SRU_UNSUPPORTED_COMBINATION_OF_PROXIMITY_MODIFIERS = 44; 72 public static final int SRU_UNSUPPORTED_BOOLEAN_MODIFIER = 46; 73 public static final int SRU_CANNOT_PROCESS_QUERY_REASON_UNKNOWN = 47; 74 public static final int SRU_QUERY_FEATURE_UNSUPPORTED = 48; 75 public static final int SRU_MASKING_CHARACTER_IN_UNSUPPORTED_POSITION = 49; 51 public static final String SRU_QUERY_SYNTAX_ERROR = 52 SRU_DIAGNOSTIC_URI_PREFIX + 10; 53 public static final String SRU_TOO_MANY_CHARACTERS_IN_QUERY = 54 SRU_DIAGNOSTIC_URI_PREFIX + 12; 55 public static final String SRU_INVALID_OR_UNSUPPORTED_USE_OF_PARENTHESES = 56 SRU_DIAGNOSTIC_URI_PREFIX + 13; 57 public static final String SRU_INVALID_OR_UNSUPPORTED_USE_OF_QUOTES = 58 SRU_DIAGNOSTIC_URI_PREFIX + 14; 59 public static final String SRU_UNSUPPORTED_CONTEXT_SET = 60 SRU_DIAGNOSTIC_URI_PREFIX + 15; 61 public static final String SRU_UNSUPPORTED_INDEX = 62 SRU_DIAGNOSTIC_URI_PREFIX + 16; 63 public static final String SRU_UNSUPPORTED_COMBINATION_OF_INDEXES = 64 SRU_DIAGNOSTIC_URI_PREFIX + 18; 65 public static final String SRU_UNSUPPORTED_RELATION = 66 SRU_DIAGNOSTIC_URI_PREFIX + 19; 67 public static final String SRU_UNSUPPORTED_RELATION_MODIFIER = 68 SRU_DIAGNOSTIC_URI_PREFIX + 20; 69 public static final String SRU_UNSUPPORTED_COMBINATION_OF_RELATION_MODIFERS = 70 SRU_DIAGNOSTIC_URI_PREFIX + 21; 71 public static final String SRU_UNSUPPORTED_COMBINATION_OF_RELATION_AND_INDEX = 72 SRU_DIAGNOSTIC_URI_PREFIX + 22; 73 public static final String SRU_TOO_MANY_CHARACTERS_IN_TERM = 74 SRU_DIAGNOSTIC_URI_PREFIX + 23; 75 public static final String SRU_UNSUPPORTED_COMBINATION_OF_RELATION_AND_TERM = 76 SRU_DIAGNOSTIC_URI_PREFIX + 24; 77 public static final String SRU_NON_SPECIAL_CHARACTER_ESCAPED_IN_TERM = 78 SRU_DIAGNOSTIC_URI_PREFIX + 26; 79 public static final String SRU_EMPTY_TERM_UNSUPPORTED = 80 SRU_DIAGNOSTIC_URI_PREFIX + 27; 81 public static final String SRU_MASKING_CHARACTER_NOT_SUPPORTED = 82 SRU_DIAGNOSTIC_URI_PREFIX + 28; 83 public static final String SRU_MASKED_WORDS_TOO_SHORT = 84 SRU_DIAGNOSTIC_URI_PREFIX + 29; 85 public static final String SRU_TOO_MANY_MASKING_CHARACTERS_IN_TERM = 86 SRU_DIAGNOSTIC_URI_PREFIX + 30; 87 public static final String SRU_ANCHORING_CHARACTER_NOT_SUPPORTED = 88 SRU_DIAGNOSTIC_URI_PREFIX + 31; 89 public static final String SRU_ANCHORING_CHARACTER_IN_UNSUPPORTED_POSITION = 90 SRU_DIAGNOSTIC_URI_PREFIX + 32; 91 public static final String SRU_COMBINATION_OF_PROXIMITY_ADJACENCY_AND_MASKING_CHARACTERS_NOT_SUPPORTED = 92 SRU_DIAGNOSTIC_URI_PREFIX + 33; 93 public static final String SRU_COMBINATION_OF_PROXIMITY_ADJACENCY_AND_ANCHORING_CHARACTERS_NOT_SUPPORTED = 94 SRU_DIAGNOSTIC_URI_PREFIX + 34; 95 public static final String SRU_TERM_CONTAINS_ONLY_STOPWORDS = 96 SRU_DIAGNOSTIC_URI_PREFIX + 35; 97 public static final String SRU_TERM_IN_INVALID_FORMAT_FOR_INDEX_OR_RELATION = 98 SRU_DIAGNOSTIC_URI_PREFIX + 36; 99 public static final String SRU_UNSUPPORTED_BOOLEAN_OPERATOR = 100 SRU_DIAGNOSTIC_URI_PREFIX + 37; 101 public static final String SRU_TOO_MANY_BOOLEAN_OPERATORS_IN_QUERY = 102 SRU_DIAGNOSTIC_URI_PREFIX + 38; 103 public static final String SRU_PROXIMITY_NOT_SUPPORTED = 104 SRU_DIAGNOSTIC_URI_PREFIX + 39; 105 public static final String SRU_UNSUPPORTED_PROXIMITY_RELATION = 106 SRU_DIAGNOSTIC_URI_PREFIX + 40; 107 public static final String SRU_UNSUPPORTED_PROXIMITY_DISTANCE = 108 SRU_DIAGNOSTIC_URI_PREFIX + 41; 109 public static final String SRU_UNSUPPORTED_PROXIMITY_UNIT = 110 SRU_DIAGNOSTIC_URI_PREFIX + 42; 111 public static final String SRU_UNSUPPORTED_PROXIMITY_ORDERING = 112 SRU_DIAGNOSTIC_URI_PREFIX + 43; 113 public static final String SRU_UNSUPPORTED_COMBINATION_OF_PROXIMITY_MODIFIERS = 114 SRU_DIAGNOSTIC_URI_PREFIX + 44; 115 public static final String SRU_UNSUPPORTED_BOOLEAN_MODIFIER = 116 SRU_DIAGNOSTIC_URI_PREFIX + 46; 117 public static final String SRU_CANNOT_PROCESS_QUERY_REASON_UNKNOWN = 118 SRU_DIAGNOSTIC_URI_PREFIX + 47; 119 public static final String SRU_QUERY_FEATURE_UNSUPPORTED = 120 SRU_DIAGNOSTIC_URI_PREFIX + 48; 121 public static final String SRU_MASKING_CHARACTER_IN_UNSUPPORTED_POSITION = 122 SRU_DIAGNOSTIC_URI_PREFIX + 49; 76 123 // diagnostics relating to result sets 77 public static final int SRU_RESULT_SETS_NOT_SUPPORTED = 50; 78 public static final int SRU_RESULT_SET_DOES_NOT_EXIST = 51; 79 public static final int SRU_RESULT_SET_TEMPORARILY_UNAVAILABLE = 52; 80 public static final int SRU_RESULT_SETS_ONLY_SUPPORTED_FOR_RETRIEVAL = 53; 81 public static final int SRU_COMBINATION_OF_RESULT_SETS_WITH_SEARCH_TERMS_NOT_SUPPORTED = 55; 82 public static final int SRU_RESULT_SET_CREATED_WITH_UNPREDICTABLE_PARTIAL_RESULTS_AVAILABLE = 58; 83 public static final int SRU_RESULT_SET_CREATED_WITH_VALID_PARTIAL_RESULTS_AVAILABLE = 59; 84 public static final int SRU_RESULT_SET_NOT_CREATED_TOO_MANY_MATCHING_RECORDS = 60; 124 public static final String SRU_RESULT_SETS_NOT_SUPPORTED = 125 SRU_DIAGNOSTIC_URI_PREFIX + 50; 126 public static final String SRU_RESULT_SET_DOES_NOT_EXIST = 127 SRU_DIAGNOSTIC_URI_PREFIX + 51; 128 public static final String SRU_RESULT_SET_TEMPORARILY_UNAVAILABLE = 129 SRU_DIAGNOSTIC_URI_PREFIX + 52; 130 public static final String SRU_RESULT_SETS_ONLY_SUPPORTED_FOR_RETRIEVAL = 131 SRU_DIAGNOSTIC_URI_PREFIX + 53; 132 public static final String SRU_COMBINATION_OF_RESULT_SETS_WITH_SEARCH_TERMS_NOT_SUPPORTED = 133 SRU_DIAGNOSTIC_URI_PREFIX + 55; 134 public static final String SRU_RESULT_SET_CREATED_WITH_UNPREDICTABLE_PARTIAL_RESULTS_AVAILABLE = 135 SRU_DIAGNOSTIC_URI_PREFIX + 58; 136 public static final String SRU_RESULT_SET_CREATED_WITH_VALID_PARTIAL_RESULTS_AVAILABLE = 137 SRU_DIAGNOSTIC_URI_PREFIX + 59; 138 public static final String SRU_RESULT_SET_NOT_CREATED_TOO_MANY_MATCHING_RECORDS = 139 SRU_DIAGNOSTIC_URI_PREFIX + 60; 85 140 // diagnostics relating to records 86 public static final int SRU_FIRST_RECORD_POSITION_OUT_OF_RANGE = 61; 87 public static final int SRU_RECORD_TEMPORARILY_UNAVAILABLE = 64; 88 public static final int SRU_RECORD_DOES_NOT_EXIST = 65; 89 public static final int SRU_UNKNOWN_SCHEMA_FOR_RETRIEVAL = 66; 90 public static final int SRU_RECORD_NOT_AVAILABLE_IN_THIS_SCHEMA = 67; 91 public static final int SRU_NOT_AUTHORISED_TO_SEND_RECORD = 68; 92 public static final int SRU_NOT_AUTHORISED_TO_SEND_RECORD_IN_THIS_SCHEMA = 69; 93 public static final int SRU_RECORD_TOO_LARGE_TO_SEND = 70; 94 public static final int SRU_UNSUPPORTED_RECORD_PACKING = 71; 95 public static final int SRU_XPATH_RETRIEVAL_UNSUPPORTED = 72; 96 public static final int SRU_XPATH_EXPRESSION_CONTAINS_UNSUPPORTED_FEATURE = 73; 97 public static final int SRU_UNABLE_TO_EVALUATE_XPATH_EXPRESSION = 74; 141 public static final String SRU_FIRST_RECORD_POSITION_OUT_OF_RANGE = 142 SRU_DIAGNOSTIC_URI_PREFIX + 61; 143 public static final String SRU_RECORD_TEMPORARILY_UNAVAILABLE = 144 SRU_DIAGNOSTIC_URI_PREFIX + 64; 145 public static final String SRU_RECORD_DOES_NOT_EXIST = 146 SRU_DIAGNOSTIC_URI_PREFIX + 65; 147 public static final String SRU_UNKNOWN_SCHEMA_FOR_RETRIEVAL = 148 SRU_DIAGNOSTIC_URI_PREFIX + 66; 149 public static final String SRU_RECORD_NOT_AVAILABLE_IN_THIS_SCHEMA = 150 SRU_DIAGNOSTIC_URI_PREFIX + 67; 151 public static final String SRU_NOT_AUTHORISED_TO_SEND_RECORD = 152 SRU_DIAGNOSTIC_URI_PREFIX + 68; 153 public static final String SRU_NOT_AUTHORISED_TO_SEND_RECORD_IN_THIS_SCHEMA = 154 SRU_DIAGNOSTIC_URI_PREFIX + 69; 155 public static final String SRU_RECORD_TOO_LARGE_TO_SEND = 156 SRU_DIAGNOSTIC_URI_PREFIX + 70; 157 public static final String SRU_UNSUPPORTED_RECORD_PACKING = 158 SRU_DIAGNOSTIC_URI_PREFIX + 71; 159 public static final String SRU_XPATH_RETRIEVAL_UNSUPPORTED = 160 SRU_DIAGNOSTIC_URI_PREFIX + 72; 161 public static final String SRU_XPATH_EXPRESSION_CONTAINS_UNSUPPORTED_FEATURE = 162 SRU_DIAGNOSTIC_URI_PREFIX + 73; 163 public static final String SRU_UNABLE_TO_EVALUATE_XPATH_EXPRESSION = 164 SRU_DIAGNOSTIC_URI_PREFIX + 74; 98 165 // diagnostics relating to sorting 99 public static final int SRU_SORT_NOT_SUPPORTED = 80; 100 public static final int SRU_UNSUPPORTED_SORT_SEQUENCE = 82; 101 public static final int SRU_TOO_MANY_RECORDS_TO_SORT = 83; 102 public static final int SRU_TOO_MANY_SORT_KEYS_TO_SORT = 84; 103 public static final int SRU_CANNOT_SORT_INCOMPATIBLE_RECORD_FORMATS = 86; 104 public static final int SRU_UNSUPPORTED_SCHEMA_FOR_SORT = 87; 105 public static final int SRU_UNSUPPORTED_PATH_FOR_SORT = 88; 106 public static final int SRU_PATH_UNSUPPORTED_FOR_SCHEMA = 89; 107 public static final int SRU_UNSUPPORTED_DIRECTION = 90; 108 public static final int SRU_UNSUPPORTED_CASE = 91; 109 public static final int SRU_UNSUPPORTED_MISSING_VALUE_ACTION = 92; 110 public static final int SRU_SORT_ENDED_DUE_TO_MISSING_VALUE = 93; 111 public static final int SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_QUERY_PREVAILS = 94; 112 public static final int SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_PROTOCOL_PREVAILS = 95; 113 public static final int SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_ERROR = 96; 166 public static final String SRU_SORT_NOT_SUPPORTED = 167 SRU_DIAGNOSTIC_URI_PREFIX + 80; 168 public static final String SRU_UNSUPPORTED_SORT_SEQUENCE = 169 SRU_DIAGNOSTIC_URI_PREFIX + 82; 170 public static final String SRU_TOO_MANY_RECORDS_TO_SORT = 171 SRU_DIAGNOSTIC_URI_PREFIX + 83; 172 public static final String SRU_TOO_MANY_SORT_KEYS_TO_SORT = 173 SRU_DIAGNOSTIC_URI_PREFIX + 84; 174 public static final String SRU_CANNOT_SORT_INCOMPATIBLE_RECORD_FORMATS = 175 SRU_DIAGNOSTIC_URI_PREFIX + 86; 176 public static final String SRU_UNSUPPORTED_SCHEMA_FOR_SORT = 177 SRU_DIAGNOSTIC_URI_PREFIX + 87; 178 public static final String SRU_UNSUPPORTED_PATH_FOR_SORT = 179 SRU_DIAGNOSTIC_URI_PREFIX + 88; 180 public static final String SRU_PATH_UNSUPPORTED_FOR_SCHEMA = 181 SRU_DIAGNOSTIC_URI_PREFIX + 89; 182 public static final String SRU_UNSUPPORTED_DIRECTION = 183 SRU_DIAGNOSTIC_URI_PREFIX + 90; 184 public static final String SRU_UNSUPPORTED_CASE = 185 SRU_DIAGNOSTIC_URI_PREFIX + 91; 186 public static final String SRU_UNSUPPORTED_MISSING_VALUE_ACTION = 187 SRU_DIAGNOSTIC_URI_PREFIX + 92; 188 public static final String SRU_SORT_ENDED_DUE_TO_MISSING_VALUE = 189 SRU_DIAGNOSTIC_URI_PREFIX + 93; 190 public static final String SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_QUERY_PREVAILS = 191 SRU_DIAGNOSTIC_URI_PREFIX + 94; 192 public static final String SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_PROTOCOL_PREVAILS = 193 SRU_DIAGNOSTIC_URI_PREFIX + 95; 194 public static final String SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_ERROR = 195 SRU_DIAGNOSTIC_URI_PREFIX + 96; 114 196 // diagnostics relating to stylesheets 115 public static final int SRU_STYLESHEETS_NOT_SUPPORTED = 110; 116 public static final int SRU_UNSUPPORTED_STYLESHEET = 111; 197 public static final String SRU_STYLESHEETS_NOT_SUPPORTED = 198 SRU_DIAGNOSTIC_URI_PREFIX + 110; 199 public static final String SRU_UNSUPPORTED_STYLESHEET = 200 SRU_DIAGNOSTIC_URI_PREFIX + 111; 117 201 // diagnostics relating to scan 118 public static final int SRU_RESPONSE_POSITION_OUT_OF_RANGE = 120; 119 public static final int SRU_TOO_MANY_TERMS_REQUESTED = 121; 120 121 public static final String SRU_DIAGNOSTIC_URI_PREFIX = "info:srw/diagnostic/1/"; 202 public static final String SRU_RESPONSE_POSITION_OUT_OF_RANGE = 203 SRU_DIAGNOSTIC_URI_PREFIX + 120; 204 public static final String SRU_TOO_MANY_TERMS_REQUESTED = 205 SRU_DIAGNOSTIC_URI_PREFIX + 121; 206 122 207 123 208 /* hide constructor */ -
SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUDiagnostic.java
r2623 r5924 28 28 */ 29 29 public final class SRUDiagnostic { 30 private final int code;30 private final String uri; 31 31 private final String details; 32 32 private final String message; … … 36 36 * Constructor. 37 37 * 38 * @param code39 * numerical diagnostic code38 * @param uri 39 * the diagnostic's identifying URI 40 40 * @param details 41 41 * supplementary information available, often in a format … … 44 44 * human readable message to display to the end user or 45 45 * <code>null</code> 46 */ 47 public SRUDiagnostic(int code, String details, String message) { 48 this.code = code; 46 * @throws NullPointerException 47 * if uri is <code>null</code> 48 * @throws IllegalArgumentException 49 * if uri is empty string 50 */ 51 public SRUDiagnostic(String uri, String details, String message) { 52 if (uri == null) { 53 throw new NullPointerException("uri == null"); 54 } 55 uri = uri.trim(); 56 if (uri.isEmpty()) { 57 throw new IllegalArgumentException("uri is empty"); 58 } 59 this.uri = uri; 60 if (details != null) { 61 details = details.trim(); 62 if (details.isEmpty()) { 63 details = null; 64 } 65 } 49 66 this.details = details; 67 if (message != null) { 68 message = message.trim(); 69 if (message.isEmpty()) { 70 message = null; 71 } 72 } 50 73 this.message = message; 51 74 } … … 55 78 * Constructor. 56 79 * 57 * @param code58 * numerical diagnostic code80 * @param uri 81 * the diagnostic's identifying URI 59 82 * @param details 60 83 * supplementary information available, often in a format 61 84 * specified by the diagnostic or <code>null</code> 62 85 */ 63 public SRUDiagnostic( int code, String details) {64 this( code, details, null);86 public SRUDiagnostic(String uri, String details) { 87 this(uri, details, null); 65 88 } 66 89 … … 69 92 * Constructor. 70 93 * 71 * @param code72 * numerical diagnostic code73 */ 74 public SRUDiagnostic( int code) {75 this( code, null, null);94 * @param uri 95 * the diagnostic's identifying URI 96 */ 97 public SRUDiagnostic(String uri) { 98 this(uri, null, null); 76 99 } 77 100 … … 83 106 * @see SRUConstants 84 107 */ 85 public int getCode() {86 return code;108 public String getURI() { 109 return uri; 87 110 } 88 111 … … 105 128 */ 106 129 public String getMessage() { 107 return message != null ? message : getDefaultErrorMessage(code); 108 } 109 110 111 private static String getDefaultErrorMessage(int code) { 112 switch (code) { 113 case SRUConstants.SRU_GENERAL_SYSTEM_ERROR: 130 return message != null ? message : getDefaultErrorMessage(uri); 131 } 132 133 134 private static String getDefaultErrorMessage(final String uri) { 135 /* 136 * Ugly, but can't do better unless we drop JDK 1.6 compatibility. 137 * (JDK 1.7+ has switch on String) 138 */ 139 if (uri.equals(SRUConstants.SRU_GENERAL_SYSTEM_ERROR)) { 114 140 return "General system error"; 115 case SRUConstants.SRU_SYSTEM_TEMPORARILY_UNAVAILABLE:141 } else if (uri.equals(SRUConstants.SRU_SYSTEM_TEMPORARILY_UNAVAILABLE)) { 116 142 return "System temporarily unavailable"; 117 case SRUConstants.SRU_AUTHENTICATION_ERROR:143 } else if (uri.equals(SRUConstants.SRU_AUTHENTICATION_ERROR)) { 118 144 return "Authentication error"; 119 case SRUConstants.SRU_UNSUPPORTED_OPERATION:145 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_OPERATION)) { 120 146 return "Unsupported operation"; 121 case SRUConstants.SRU_UNSUPPORTED_VERSION:147 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_VERSION)) { 122 148 return "Unsupported version"; 123 case SRUConstants.SRU_UNSUPPORTED_PARAMETER_VALUE:149 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_PARAMETER_VALUE)) { 124 150 return "Unsupported parameter value"; 125 case SRUConstants.SRU_MANDATORY_PARAMETER_NOT_SUPPLIED:151 } else if (uri.equals(SRUConstants.SRU_MANDATORY_PARAMETER_NOT_SUPPLIED)) { 126 152 return "Mandatory parameter not supplied"; 127 case SRUConstants.SRU_UNSUPPORTED_PARAMETER:153 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_PARAMETER)) { 128 154 return "Unsupported Parameter"; 129 case SRUConstants.SRU_QUERY_SYNTAX_ERROR:155 } else if (uri.equals(SRUConstants.SRU_QUERY_SYNTAX_ERROR)) { 130 156 return "Query syntax error"; 131 case SRUConstants.SRU_TOO_MANY_CHARACTERS_IN_QUERY:157 } else if (uri.equals(SRUConstants.SRU_TOO_MANY_CHARACTERS_IN_QUERY)) { 132 158 return "Too many characters in query"; 133 case SRUConstants.SRU_INVALID_OR_UNSUPPORTED_USE_OF_PARENTHESES:159 } else if (uri.equals(SRUConstants.SRU_INVALID_OR_UNSUPPORTED_USE_OF_PARENTHESES)) { 134 160 return "Invalid or unsupported use of parentheses"; 135 case SRUConstants.SRU_INVALID_OR_UNSUPPORTED_USE_OF_QUOTES:161 } else if (uri.equals(SRUConstants.SRU_INVALID_OR_UNSUPPORTED_USE_OF_QUOTES)) { 136 162 return "Invalid or unsupported use of quotes"; 137 case SRUConstants.SRU_UNSUPPORTED_CONTEXT_SET:163 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_CONTEXT_SET)) { 138 164 return "Unsupported context set"; 139 case SRUConstants.SRU_UNSUPPORTED_INDEX:165 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_INDEX)) { 140 166 return "Unsupported index"; 141 case SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_INDEXES:167 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_INDEXES)) { 142 168 return "Unsupported combination of indexes"; 143 case SRUConstants.SRU_UNSUPPORTED_RELATION:169 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_RELATION)) { 144 170 return "Unsupported relation"; 145 case SRUConstants.SRU_UNSUPPORTED_RELATION_MODIFIER:171 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_RELATION_MODIFIER)) { 146 172 return "Unsupported relation modifier"; 147 case SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_RELATION_MODIFERS:173 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_RELATION_MODIFERS)) { 148 174 return "Unsupported combination of relation modifers"; 149 case SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_RELATION_AND_INDEX:175 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_RELATION_AND_INDEX)) { 150 176 return "Unsupported combination of relation and index"; 151 case SRUConstants.SRU_TOO_MANY_CHARACTERS_IN_TERM:177 } else if (uri.equals(SRUConstants.SRU_TOO_MANY_CHARACTERS_IN_TERM)) { 152 178 return "Too many characters in term"; 153 case SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_RELATION_AND_TERM:179 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_RELATION_AND_TERM)) { 154 180 return "Unsupported combination of relation and term"; 155 case SRUConstants.SRU_NON_SPECIAL_CHARACTER_ESCAPED_IN_TERM:181 } else if (uri.equals(SRUConstants.SRU_NON_SPECIAL_CHARACTER_ESCAPED_IN_TERM)) { 156 182 return "Non special character escaped in term"; 157 case SRUConstants.SRU_EMPTY_TERM_UNSUPPORTED:183 } else if (uri.equals(SRUConstants.SRU_EMPTY_TERM_UNSUPPORTED)) { 158 184 return "Empty term unsupported"; 159 case SRUConstants.SRU_MASKING_CHARACTER_NOT_SUPPORTED:185 } else if (uri.equals(SRUConstants.SRU_MASKING_CHARACTER_NOT_SUPPORTED)) { 160 186 return "Masking character not supported"; 161 case SRUConstants.SRU_MASKED_WORDS_TOO_SHORT:187 } else if (uri.equals(SRUConstants.SRU_MASKED_WORDS_TOO_SHORT)) { 162 188 return "Masked words too short"; 163 case SRUConstants.SRU_TOO_MANY_MASKING_CHARACTERS_IN_TERM:189 } else if (uri.equals(SRUConstants.SRU_TOO_MANY_MASKING_CHARACTERS_IN_TERM)) { 164 190 return "Too many masking characters in term"; 165 case SRUConstants.SRU_ANCHORING_CHARACTER_NOT_SUPPORTED:191 } else if (uri.equals(SRUConstants.SRU_ANCHORING_CHARACTER_NOT_SUPPORTED)) { 166 192 return "Anchoring character not supported"; 167 case SRUConstants.SRU_ANCHORING_CHARACTER_IN_UNSUPPORTED_POSITION:193 } else if (uri.equals(SRUConstants.SRU_ANCHORING_CHARACTER_IN_UNSUPPORTED_POSITION)) { 168 194 return "Anchoring character in unsupported position"; 169 case SRUConstants.SRU_COMBINATION_OF_PROXIMITY_ADJACENCY_AND_MASKING_CHARACTERS_NOT_SUPPORTED:195 } else if (uri.equals(SRUConstants.SRU_COMBINATION_OF_PROXIMITY_ADJACENCY_AND_MASKING_CHARACTERS_NOT_SUPPORTED)) { 170 196 return "Combination of proximity adjacency and masking characters not supported"; 171 case SRUConstants.SRU_COMBINATION_OF_PROXIMITY_ADJACENCY_AND_ANCHORING_CHARACTERS_NOT_SUPPORTED:197 } else if (uri.equals(SRUConstants.SRU_COMBINATION_OF_PROXIMITY_ADJACENCY_AND_ANCHORING_CHARACTERS_NOT_SUPPORTED)) { 172 198 return "Combination of proximity adjacency and anchoring characters not supported"; 173 case SRUConstants.SRU_TERM_CONTAINS_ONLY_STOPWORDS:199 } else if (uri.equals(SRUConstants.SRU_TERM_CONTAINS_ONLY_STOPWORDS)) { 174 200 return "Term contains only stopwords"; 175 case SRUConstants.SRU_TERM_IN_INVALID_FORMAT_FOR_INDEX_OR_RELATION:201 } else if (uri.equals(SRUConstants.SRU_TERM_IN_INVALID_FORMAT_FOR_INDEX_OR_RELATION)) { 176 202 return "Term in invalid format for index or relation"; 177 case SRUConstants.SRU_UNSUPPORTED_BOOLEAN_OPERATOR:203 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_BOOLEAN_OPERATOR)) { 178 204 return "Unsupported boolean operator"; 179 case SRUConstants.SRU_TOO_MANY_BOOLEAN_OPERATORS_IN_QUERY:205 } else if (uri.equals(SRUConstants.SRU_TOO_MANY_BOOLEAN_OPERATORS_IN_QUERY)) { 180 206 return "Too many boolean operators in query"; 181 case SRUConstants.SRU_PROXIMITY_NOT_SUPPORTED:207 } else if (uri.equals(SRUConstants.SRU_PROXIMITY_NOT_SUPPORTED)) { 182 208 return "Proximity not supported"; 183 case SRUConstants.SRU_UNSUPPORTED_PROXIMITY_RELATION:209 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_PROXIMITY_RELATION)) { 184 210 return "Unsupported proximity relation"; 185 case SRUConstants.SRU_UNSUPPORTED_PROXIMITY_DISTANCE:211 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_PROXIMITY_DISTANCE)) { 186 212 return "Unsupported proximity distance"; 187 case SRUConstants.SRU_UNSUPPORTED_PROXIMITY_UNIT:213 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_PROXIMITY_UNIT)) { 188 214 return "Unsupported proximity unit"; 189 case SRUConstants.SRU_UNSUPPORTED_PROXIMITY_ORDERING:215 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_PROXIMITY_ORDERING)) { 190 216 return "Unsupported proximity ordering"; 191 case SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_PROXIMITY_MODIFIERS:217 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_PROXIMITY_MODIFIERS)) { 192 218 return "Unsupported combination of proximity modifiers"; 193 case SRUConstants.SRU_UNSUPPORTED_BOOLEAN_MODIFIER:219 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_BOOLEAN_MODIFIER)) { 194 220 return "Unsupported boolean modifier"; 195 case SRUConstants.SRU_CANNOT_PROCESS_QUERY_REASON_UNKNOWN:221 } else if (uri.equals(SRUConstants.SRU_CANNOT_PROCESS_QUERY_REASON_UNKNOWN)) { 196 222 return "Cannot process query; reason unknown"; 197 case SRUConstants.SRU_QUERY_FEATURE_UNSUPPORTED:223 } else if (uri.equals(SRUConstants.SRU_QUERY_FEATURE_UNSUPPORTED)) { 198 224 return "Query feature unsupported"; 199 case SRUConstants.SRU_MASKING_CHARACTER_IN_UNSUPPORTED_POSITION:225 } else if (uri.equals(SRUConstants.SRU_MASKING_CHARACTER_IN_UNSUPPORTED_POSITION)) { 200 226 return "Masking character in unsupported position"; 201 case SRUConstants.SRU_RESULT_SETS_NOT_SUPPORTED:227 } else if (uri.equals(SRUConstants.SRU_RESULT_SETS_NOT_SUPPORTED)) { 202 228 return "Result sets not supported"; 203 case SRUConstants.SRU_RESULT_SET_DOES_NOT_EXIST:229 } else if (uri.equals(SRUConstants.SRU_RESULT_SET_DOES_NOT_EXIST)) { 204 230 return "Result set does not exist"; 205 case SRUConstants.SRU_RESULT_SET_TEMPORARILY_UNAVAILABLE:231 } else if (uri.equals(SRUConstants.SRU_RESULT_SET_TEMPORARILY_UNAVAILABLE)) { 206 232 return "Result set temporarily unavailable"; 207 case SRUConstants.SRU_RESULT_SETS_ONLY_SUPPORTED_FOR_RETRIEVAL:233 } else if (uri.equals(SRUConstants.SRU_RESULT_SETS_ONLY_SUPPORTED_FOR_RETRIEVAL)) { 208 234 return "Result sets only supported for retrieval"; 209 case SRUConstants.SRU_COMBINATION_OF_RESULT_SETS_WITH_SEARCH_TERMS_NOT_SUPPORTED:235 } else if (uri.equals(SRUConstants.SRU_COMBINATION_OF_RESULT_SETS_WITH_SEARCH_TERMS_NOT_SUPPORTED)) { 210 236 return "Combination of result sets with search terms not supported"; 211 case SRUConstants.SRU_RESULT_SET_CREATED_WITH_UNPREDICTABLE_PARTIAL_RESULTS_AVAILABLE:237 } else if (uri.equals(SRUConstants.SRU_RESULT_SET_CREATED_WITH_UNPREDICTABLE_PARTIAL_RESULTS_AVAILABLE)) { 212 238 return "Result set created with unpredictable partial results available"; 213 case SRUConstants.SRU_RESULT_SET_CREATED_WITH_VALID_PARTIAL_RESULTS_AVAILABLE:239 } else if (uri.equals(SRUConstants.SRU_RESULT_SET_CREATED_WITH_VALID_PARTIAL_RESULTS_AVAILABLE)) { 214 240 return "Result set created with valid partial results available"; 215 case SRUConstants.SRU_RESULT_SET_NOT_CREATED_TOO_MANY_MATCHING_RECORDS:216 return "Result set not created :too many matching records";217 case SRUConstants.SRU_FIRST_RECORD_POSITION_OUT_OF_RANGE:241 } else if (uri.equals(SRUConstants.SRU_RESULT_SET_NOT_CREATED_TOO_MANY_MATCHING_RECORDS)) { 242 return "Result set not created)) { too many matching records"; 243 } else if (uri.equals(SRUConstants.SRU_FIRST_RECORD_POSITION_OUT_OF_RANGE)) { 218 244 return "First record position out of range"; 219 case SRUConstants.SRU_RECORD_TEMPORARILY_UNAVAILABLE:245 } else if (uri.equals(SRUConstants.SRU_RECORD_TEMPORARILY_UNAVAILABLE)) { 220 246 return "Record temporarily unavailable"; 221 case SRUConstants.SRU_RECORD_DOES_NOT_EXIST:247 } else if (uri.equals(SRUConstants.SRU_RECORD_DOES_NOT_EXIST)) { 222 248 return "Record does not exist"; 223 case SRUConstants.SRU_UNKNOWN_SCHEMA_FOR_RETRIEVAL:249 } else if (uri.equals(SRUConstants.SRU_UNKNOWN_SCHEMA_FOR_RETRIEVAL)) { 224 250 return "Unknown schema for retrieval"; 225 case SRUConstants.SRU_RECORD_NOT_AVAILABLE_IN_THIS_SCHEMA:251 } else if (uri.equals(SRUConstants.SRU_RECORD_NOT_AVAILABLE_IN_THIS_SCHEMA)) { 226 252 return "Record not available in this schema"; 227 case SRUConstants.SRU_NOT_AUTHORISED_TO_SEND_RECORD:253 } else if (uri.equals(SRUConstants.SRU_NOT_AUTHORISED_TO_SEND_RECORD)) { 228 254 return "Not authorised to send record"; 229 case SRUConstants.SRU_NOT_AUTHORISED_TO_SEND_RECORD_IN_THIS_SCHEMA:255 } else if (uri.equals(SRUConstants.SRU_NOT_AUTHORISED_TO_SEND_RECORD_IN_THIS_SCHEMA)) { 230 256 return "Not authorised to send record in this schema"; 231 case SRUConstants.SRU_RECORD_TOO_LARGE_TO_SEND:257 } else if (uri.equals(SRUConstants.SRU_RECORD_TOO_LARGE_TO_SEND)) { 232 258 return "Record too large to send"; 233 case SRUConstants.SRU_UNSUPPORTED_RECORD_PACKING:259 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_RECORD_PACKING)) { 234 260 return "Unsupported record packing"; 235 case SRUConstants.SRU_XPATH_RETRIEVAL_UNSUPPORTED:261 } else if (uri.equals(SRUConstants.SRU_XPATH_RETRIEVAL_UNSUPPORTED)) { 236 262 return "XPath retrieval unsupported"; 237 case SRUConstants.SRU_XPATH_EXPRESSION_CONTAINS_UNSUPPORTED_FEATURE:263 } else if (uri.equals(SRUConstants.SRU_XPATH_EXPRESSION_CONTAINS_UNSUPPORTED_FEATURE)) { 238 264 return "XPath expression contains unsupported feature"; 239 case SRUConstants.SRU_UNABLE_TO_EVALUATE_XPATH_EXPRESSION:265 } else if (uri.equals(SRUConstants.SRU_UNABLE_TO_EVALUATE_XPATH_EXPRESSION)) { 240 266 return "Unable to evaluate XPath expression"; 241 case SRUConstants.SRU_SORT_NOT_SUPPORTED:267 } else if (uri.equals(SRUConstants.SRU_SORT_NOT_SUPPORTED)) { 242 268 return "Sort not supported"; 243 case SRUConstants.SRU_UNSUPPORTED_SORT_SEQUENCE:269 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_SORT_SEQUENCE)) { 244 270 return "Unsupported sort sequence"; 245 case SRUConstants.SRU_TOO_MANY_RECORDS_TO_SORT:271 } else if (uri.equals(SRUConstants.SRU_TOO_MANY_RECORDS_TO_SORT)) { 246 272 return "Too many records to sort"; 247 case SRUConstants.SRU_TOO_MANY_SORT_KEYS_TO_SORT:273 } else if (uri.equals(SRUConstants.SRU_TOO_MANY_SORT_KEYS_TO_SORT)) { 248 274 return "Too many sort keys to sort"; 249 case SRUConstants.SRU_CANNOT_SORT_INCOMPATIBLE_RECORD_FORMATS:275 } else if (uri.equals(SRUConstants.SRU_CANNOT_SORT_INCOMPATIBLE_RECORD_FORMATS)) { 250 276 return "Cannot sort incompatible record formats"; 251 case SRUConstants.SRU_UNSUPPORTED_SCHEMA_FOR_SORT:277 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_SCHEMA_FOR_SORT)) { 252 278 return "Unsupported schema for sort"; 253 case SRUConstants.SRU_UNSUPPORTED_PATH_FOR_SORT:279 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_PATH_FOR_SORT)) { 254 280 return "Unsupported path for sort"; 255 case SRUConstants.SRU_PATH_UNSUPPORTED_FOR_SCHEMA:281 } else if (uri.equals(SRUConstants.SRU_PATH_UNSUPPORTED_FOR_SCHEMA)) { 256 282 return "Path unsupported for schema"; 257 case SRUConstants.SRU_UNSUPPORTED_DIRECTION:283 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_DIRECTION)) { 258 284 return "Unsupported direction"; 259 case SRUConstants.SRU_UNSUPPORTED_CASE:260 return "Unsupported case";261 case SRUConstants.SRU_UNSUPPORTED_MISSING_VALUE_ACTION:285 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_CASE)) { 286 return "Unsupported } else if (uri.equals("; 287 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_MISSING_VALUE_ACTION)) { 262 288 return "Unsupported missing value action"; 263 case SRUConstants.SRU_SORT_ENDED_DUE_TO_MISSING_VALUE:289 } else if (uri.equals(SRUConstants.SRU_SORT_ENDED_DUE_TO_MISSING_VALUE)) { 264 290 return "Sort ended due to missing value"; 265 case SRUConstants.SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_QUERY_PREVAILS:291 } else if (uri.equals(SRUConstants.SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_QUERY_PREVAILS)) { 266 292 return "Sort spec included both in query and protocol query prevails"; 267 case SRUConstants.SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_PROTOCOL_PREVAILS:293 } else if (uri.equals(SRUConstants.SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_PROTOCOL_PREVAILS)) { 268 294 return "Sort spec included both in query and protocol protocol prevails"; 269 case SRUConstants.SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_ERROR:295 } else if (uri.equals(SRUConstants.SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_ERROR)) { 270 296 return "Sort spec included both in query and protocol error"; 271 case SRUConstants.SRU_STYLESHEETS_NOT_SUPPORTED:297 } else if (uri.equals(SRUConstants.SRU_STYLESHEETS_NOT_SUPPORTED)) { 272 298 return "Stylesheets not supported"; 273 case SRUConstants.SRU_UNSUPPORTED_STYLESHEET:299 } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_STYLESHEET)) { 274 300 return "Unsupported stylesheet"; 275 case SRUConstants.SRU_RESPONSE_POSITION_OUT_OF_RANGE:301 } else if (uri.equals(SRUConstants.SRU_RESPONSE_POSITION_OUT_OF_RANGE)) { 276 302 return "Response position out of range"; 277 case SRUConstants.SRU_TOO_MANY_TERMS_REQUESTED:303 } else if (uri.equals(SRUConstants.SRU_TOO_MANY_TERMS_REQUESTED)) { 278 304 return "Too many terms requested"; 279 default:305 } else { 280 306 return null; 281 } // switch307 } 282 308 } 283 309 -
SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUDiagnosticList.java
r2623 r5924 33 33 * Add a non surrogate diagnostic to the response. 34 34 * 35 * @param code36 * numerical diagnostic code35 * @param uri 36 * the diagnostic's identifying URI 37 37 * @param details 38 38 * supplementary information available, often in a format … … 42 42 * <code>null</code> 43 43 */ 44 public void addDiagnostic( int code, String details, String message);44 public void addDiagnostic(String uri, String details, String message); 45 45 46 46 } // interface DiagnosticList -
SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUException.java
r2682 r5924 25 25 @SuppressWarnings("serial") 26 26 public class SRUException extends Exception { 27 private final int code;27 private final String uri; 28 28 private final String details; 29 29 … … 32 32 * Constructor. 33 33 * 34 * @param code35 * the diagnostic code34 * @param uri 35 * the diagnostic's identifying URI 36 36 * @param details 37 37 * diagnostic details or <code>null</code> … … 41 41 * the cause of the error or <code>null</code> 42 42 */ 43 public SRUException( int code, String details, String message,43 public SRUException(String uri, String details, String message, 44 44 Throwable cause) { 45 45 super(message, cause); 46 this.code = code; 46 if (uri == null) { 47 throw new NullPointerException("uri == null"); 48 } 49 uri = uri.trim(); 50 if (uri.isEmpty()) { 51 throw new IllegalArgumentException("uri is empty"); 52 } 53 this.uri = uri; 47 54 this.details = details; 48 55 } … … 52 59 * Constructor. 53 60 * 54 * @param code55 * the diagnostic code61 * @param uri 62 * the diagnostic's identifying URI 56 63 * @param details 57 64 * diagnostic details or <code>null</code> … … 59 66 * diagnostic message or <code>null</code> 60 67 */ 61 public SRUException( int code, String details, String message) {62 this( code, details, message, null);68 public SRUException(String uri, String details, String message) { 69 this(uri, details, message, null); 63 70 } 64 71 … … 67 74 * Constructor. 68 75 * 69 * @param code70 * the diagnostic code76 * @param uri 77 * the diagnostic's identifying URI 71 78 * @param message 72 79 * diagnostic message or <code>null</code> … … 74 81 * the cause of the error or <code>null</code> 75 82 */ 76 public SRUException( int code, String message, Throwable cause) {77 this( code, null, message, cause);83 public SRUException(String uri, String message, Throwable cause) { 84 this(uri, null, message, cause); 78 85 } 79 86 … … 82 89 * Constructor. 83 90 * 84 * @param code85 * the diagnostic code91 * @param uri 92 * the diagnostic's identifying URI 86 93 * @param message 87 94 * diagnostic message or <code>null</code> 88 95 */ 89 public SRUException( int code, String message) {90 this( code, null, message, null);96 public SRUException(String uri, String message) { 97 this(uri, null, message, null); 91 98 } 92 99 … … 95 102 * Constructor. 96 103 * 97 * @param code98 * the diagnostic code104 * @param uri 105 * the diagnostic's identifying URI 99 106 * @param cause 100 107 * the cause of the error or <code>null</code> 101 108 */ 102 public SRUException( int code, Throwable cause) {103 this( code, null, null, cause);109 public SRUException(String uri, Throwable cause) { 110 this(uri, null, null, cause); 104 111 } 105 112 … … 108 115 * Constructor. 109 116 * 110 * @param code111 * the diagnostic code117 * @param uri 118 * the diagnostic's identifying URI 112 119 */ 113 public SRUException( int code) {114 this( code, null, null, null);120 public SRUException(String uri) { 121 this(uri, null, null, null); 115 122 } 116 123 … … 122 129 */ 123 130 public SRUDiagnostic getDiagnostic() { 124 return new SRUDiagnostic( code, details, this.getMessage());131 return new SRUDiagnostic(uri, details, this.getMessage()); 125 132 } 126 133 -
SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRURequestImpl.java
r5899 r5924 623 623 624 624 @Override 625 public void addDiagnostic(int code, String details, String message) { 625 public void addDiagnostic(String uri, String details, String message) { 626 final SRUDiagnostic diagnostic = 627 new SRUDiagnostic(uri, details, message); 626 628 if (diagnostics == null) { 627 629 diagnostics = new ArrayList<SRUDiagnostic>(); 628 630 } 629 diagnostics.add( new SRUDiagnostic(code, details, message));631 diagnostics.add(diagnostic); 630 632 } 631 633 -
SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUServer.java
r3001 r5924 153 153 final String message = e.getDiagnostic().getMessage(); 154 154 if (message != null) { 155 logger.info("Sending fatal diagnostic '{} {}' with " +155 logger.info("Sending fatal diagnostic '{}' with " + 156 156 "message '{}'", 157 new Object[] { 158 SRUConstants.SRU_DIAGNOSTIC_URI_PREFIX, 159 e.getDiagnostic().getCode(), 160 message 161 }); 157 e.getDiagnostic().getURI(), 158 message); 162 159 } else { 163 logger.info("Sending fatal diagnostic '{}{}'", 164 SRUConstants.SRU_DIAGNOSTIC_URI_PREFIX, 165 e.getDiagnostic().getCode()); 160 logger.info("Sending fatal diagnostic '{}'", 161 e.getDiagnostic().getURI()); 166 162 } 167 163 logger.debug("Fatal diagnostic was caused by " + … … 818 814 } 819 815 out.writeStartElement(SRU_DIAGNOSIC_NS, "uri"); 820 out.writeCharacters(SRUConstants.SRU_DIAGNOSTIC_URI_PREFIX); 821 out.writeCharacters(Integer.toString(diagnostic.getCode())); 816 out.writeCharacters(diagnostic.getURI()); 822 817 out.writeEndElement(); // "uri" element 823 818 if (diagnostic.getDetails() != null) {
Note: See TracChangeset
for help on using the changeset viewer.