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

Method run

basex-core/src/main/java/org/basex/core/cmd/BinaryPut.java:46–70  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

44 }
45
46 @Override
47 protected boolean run() {
48 final boolean create = context.user().has(Perm.CREATE);
49 String path = MetaData.normPath(args[0]);
50 if(path == null) return error(PATH_INVALID_X, args[0]);
51
52 if(in == null) {
53 final IO io = IO.get(args[1]);
54 if(!io.exists() || io.isDir()) return error(RES_NOT_FOUND_X, create ? io : args[1]);
55 in = io.inputSource();
56 // set/add name of document
57 if((path.isEmpty() || Strings.endsWith(path, '/')) && !(io instanceof IOContent)) {
58 path += io.name();
59 }
60 }
61
62 // ensure that the name is not empty and contains no trailing dots
63 final Data data = context.data();
64 if(data.inMemory()) return error(NO_MAINMEM);
65 if(path.isEmpty()) return error(PATH_INVALID_X, create ? path : args[0]);
66
67 final IOFile bin = data.meta.file(path, ResourceType.BINARY);
68 final String pth = path;
69 return update(data, () -> put(data, bin, pth));
70 }
71
72 /**
73 * Puts a binary resource in the specified database.

Callers 1

putMethod · 0.95

Calls 15

normPathMethod · 0.95
getMethod · 0.95
existsMethod · 0.95
isDirMethod · 0.95
inputSourceMethod · 0.95
endsWithMethod · 0.95
nameMethod · 0.95
inMemoryMethod · 0.95
putMethod · 0.95
hasMethod · 0.45
userMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected