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

Method init

basex-core/src/main/java/org/basex/core/CLI.java:121–144  ·  view source on GitHub ↗

Initializes and returns a session. @return session instance @throws IOException I/O exception

()

Source from the content-addressed store, hash-verified

119 * @throws IOException I/O exception
120 */
121 private Session init() throws IOException {
122 if(local()) return new LocalSession(context, out);
123
124 // user/password input
125 String username = context.soptions.get(StaticOptions.USER);
126 String password = context.soptions.get(StaticOptions.PASSWORD);
127 while(username.isEmpty()) {
128 Util.print(USERNAME + COLS);
129 username = Util.input();
130 }
131 while(password.isEmpty()) {
132 Util.print(PASSWORD + COLS);
133 password = Util.password();
134 }
135
136 final String host = context.soptions.get(StaticOptions.HOST);
137 final int port = context.soptions.get(StaticOptions.PORT);
138 try {
139 return new ClientSession(host, port, username, password, out);
140 } catch(final ConnectException ex) {
141 Util.debug(ex);
142 throw new BaseXException(CONNECTION_ERROR_X, port);
143 }
144 }
145
146 /**
147 * Returns the base URI and the query string for the specified command input.

Callers 1

sessionMethod · 0.95

Calls 7

localMethod · 0.95
printMethod · 0.95
inputMethod · 0.95
passwordMethod · 0.95
debugMethod · 0.95
getMethod · 0.65
isEmptyMethod · 0.45

Tested by

no test coverage detected