Returns a RESTXQ function that matches the current request or the specified error code best. @param conn HTTP connection @param error error code (assigned if error function is to be called) @return function, or null if no function matches @throws QueryException query exception @throws IOExce
(final HTTPConnection conn, final QNm error)
| 110 | * @throws IOException I/O exception |
| 111 | */ |
| 112 | public RestXqFunction restxq(final HTTPConnection conn, final QNm error) |
| 113 | throws QueryException, IOException { |
| 114 | |
| 115 | // collect all function candidates |
| 116 | final List<RestXqFunction> funcs = find(conn, error, false); |
| 117 | if(funcs.isEmpty()) return null; |
| 118 | |
| 119 | // multiple functions: check specifity |
| 120 | if(funcs.size() > 1) bestSpec(funcs); |
| 121 | // multiple functions: check quality factors |
| 122 | if(funcs.size() > 1) bestQf(funcs, conn); |
| 123 | // multiple functions: check consume filter |
| 124 | if(funcs.size() > 1) bestConsume(funcs, conn); |
| 125 | |
| 126 | final RestXqFunction first = funcs.get(0); |
| 127 | if(funcs.size() == 1) return first; |
| 128 | |
| 129 | // show error if we are left with multiple function candidates |
| 130 | throw first.path == null ? |
| 131 | first.error(ERROR_CONFLICT_X_X, error, toString(funcs)) : |
| 132 | first.error(PATH_CONFLICT_X_X, first.path, toString(funcs)); |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * Returns RESTXQ and permissions functions that match the current request. |