Initializes the specified input. @param ctx database context @return success flag
(final Context ctx)
| 33 | * @return success flag |
| 34 | */ |
| 35 | @Override |
| 36 | protected boolean init(final Context ctx) { |
| 37 | if(file == null) { |
| 38 | // check file reference |
| 39 | file = uri.isEmpty() ? IO.get(args[0]) : IO.get(uri).merge(args[0]); |
| 40 | if(!file.exists() || file.isDir()) { |
| 41 | error = Util.info(RES_NOT_FOUND_X, ctx.user().has(Perm.CREATE) ? file : args[0]); |
| 42 | } else { |
| 43 | try { |
| 44 | // interpret as commands if input ends with command script suffix |
| 45 | if(file.hasSuffix(IO.BXSSUFFIX)) return init(file.readString(), file.path(), ctx); |
| 46 | // otherwise, interpret input as xquery |
| 47 | commands.add(new XQuery(file.readString()).baseURI(file.path())); |
| 48 | } catch(final IOException ex) { |
| 49 | error = Util.message(ex); |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | return error == null; |
| 54 | } |
| 55 | } |
no test coverage detected