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

Method read

basex-core/src/main/java/org/basex/core/users/Users.java:51–88  ·  view source on GitHub ↗

Reads user permissions.

()

Source from the content-addressed store, hash-verified

49 * Reads user permissions.
50 */
51 private synchronized void read() {
52 if(!file.exists()) return;
53 try {
54 final MainOptions options = new MainOptions(false);
55 options.set(MainOptions.INTPARSE, true);
56 options.set(MainOptions.STRIPWS, true);
57 final XNode doc = new DBNode(Parser.singleParser(file, options, ""));
58 if(children(doc, Q_USERS).next() instanceof final XNode root) {
59 for(final GNode gchild : children(root)) {
60 final XNode child = (XNode) gchild;
61 final QNm qname = child.qname();
62 if(qname.eq(Q_USER)) {
63 try {
64 final User user = new User(child, file);
65 final String name = user.name();
66 if(users.get(name) != null) {
67 Util.errln("%: User '%' supplied more than once.", file, name);
68 } else {
69 users.put(name, user);
70 }
71 } catch(final BaseXException ex) {
72 // reject users with faulty data
73 Util.errln("%: %", file, ex.getLocalizedMessage());
74 }
75 } else if(qname.eq(Q_INFO)) {
76 if(info != null) Util.errln("%: <%/> occurs more than once.", file, qname);
77 else info = child;
78 } else {
79 Util.errln("%: invalid element <%/>.", file, qname);
80 }
81 }
82 } else {
83 Util.errln("%: No <%/> root element.", file, Q_USERS);
84 }
85 } catch(final IOException ex) {
86 Util.errln(ex);
87 }
88 }
89
90 /**
91 * Writes permissions to disk.

Callers 1

UsersMethod · 0.95

Calls 11

qnameMethod · 0.95
eqMethod · 0.95
nameMethod · 0.95
errlnMethod · 0.95
setMethod · 0.65
nextMethod · 0.65
getMethod · 0.65
existsMethod · 0.45
childrenMethod · 0.45
putMethod · 0.45
getLocalizedMessageMethod · 0.45

Tested by

no test coverage detected