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

Method run

basex-core/src/main/java/org/basex/core/cmd/AUser.java:39–58  ·  view source on GitHub ↗

Runs the command for all users and databases. @param offset offset for users and optional databases (offset + 1) @param optional indicates if user/database argument is optional @return success flag

(final int offset, final boolean optional)

Source from the content-addressed store, hash-verified

37 * @return success flag
38 */
39 final boolean run(final int offset, final boolean optional) {
40 final String name = args[offset];
41 final String db = offset + 1 < args.length ? args[offset + 1] : "";
42
43 if(!Databases.validPattern(name)) return error(NAME_INVALID_X, name);
44 if(!db.isEmpty() && !Databases.validPattern(db))
45 return error(NAME_INVALID_X, db);
46
47 // retrieve all users; stop if no user is found
48 final String[] users = context.users.find(Databases.regex(name));
49 if(users.length == 0) return info(UNKNOWN_USER_X, name) && optional;
50
51 // loop through all users
52 boolean ok = true;
53 for(final String user : users) {
54 ok &= run(user, db);
55 }
56 context.users.write();
57 return ok;
58 }
59
60 /**
61 * Runs the command for the specified user and database pattern.

Callers

nothing calls this directly

Calls 7

validPatternMethod · 0.95
regexMethod · 0.95
infoMethod · 0.65
errorMethod · 0.45
isEmptyMethod · 0.45
findMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected