MCPcopy Create free account
hub / github.com/BaseXdb/basex / get

Method get

basex-api/src/main/java/org/basex/http/rest/RESTGet.java:33–62  ·  view source on GitHub ↗

Creates and returns a REST command. @param session REST session @return code @throws QueryException query exception @throws IOException I/O exception

(final RESTSession session)

Source from the content-addressed store, hash-verified

31 * @throws IOException I/O exception
32 */
33 public static RESTCmd get(final RESTSession session) throws QueryException, IOException {
34 final Map<String, Entry<Object, String>> bindings = new HashMap<>();
35
36 // parse query string
37 String op = null, input = null;
38 final HTTPConnection conn = session.conn;
39 final Options sopts = conn.sopts(), mopts = conn.context.options;
40 for(final Entry<String, String[]> param : conn.requestCtx.queryStrings().entrySet()) {
41 final String key = param.getKey();
42 final String[] values = param.getValue();
43
44 if(Strings.eqic(key, COMMAND, QUERY, RUN)) {
45 if(op != null || values.length > 1)
46 throw HTTPStatus.MULTIPLE_OPS_X.get(String.join(", ", values));
47 op = key;
48 input = values[0];
49 } else if(key.equalsIgnoreCase(CONTEXT)) {
50 // context parameter
51 bindings.put(null, new SimpleEntry<>(values, NodeType.DOCUMENT.toString()));
52 } else if(!RESTCmd.assign(sopts, param, false) && !RESTCmd.assign(mopts, param, false)) {
53 // assign database option, serialization parameter or external variable
54 bindings.put(key, new SimpleEntry<>(values, null));
55 }
56 }
57
58 if(op == null) return RESTRetrieve.get(session);
59 if(op.equals(QUERY)) return RESTQuery.get(session, input, bindings);
60 if(op.equals(RUN)) return RESTRun.get(session, input, bindings);
61 return RESTCommands.get(session, input, true);
62 }
63}

Callers 1

commandMethod · 0.95

Calls 15

soptsMethod · 0.95
eqicMethod · 0.95
assignMethod · 0.95
getMethod · 0.95
getMethod · 0.95
getMethod · 0.95
getMethod · 0.95
queryStringsMethod · 0.80
getKeyMethod · 0.80
getMethod · 0.65
toStringMethod · 0.65
getValueMethod · 0.45

Tested by

no test coverage detected