/* (non-Javadoc) * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence) */ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { if (!context.getSubject().hasDbaRole()) { XPathException xPathException = new XPathException( this, "Permission denied, calling user '" + context.getSubject().getName() + "' must be a DBA to call this function."); logger.error("Invalid user", xPathException); throw xPathException; } Sequence created = BooleanValue.FALSE; String inputPath = args[0].itemAt(0).getStringValue(); File file = FileModuleHelper.getFile(inputPath); if (isCalledAs("mkdir")) { if (file.mkdir()) { created = BooleanValue.TRUE; } } else if (isCalledAs("mkdirs")) { if (file.mkdirs()) { created = BooleanValue.TRUE; } } return created; }
/* (non-Javadoc) * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence) */ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { if (!context.getUser().hasDbaRole()) { XPathException xPathException = new XPathException( this, "Permission denied, calling user '" + context.getUser().getName() + "' must be a DBA to call this function."); logger.error("Invalid user", xPathException); throw xPathException; } Sequence isDir = BooleanValue.FALSE; String inputPath = args[0].getStringValue(); File file = FileModuleHelper.getFile(inputPath); if (file.isDirectory()) { isDir = BooleanValue.TRUE; } return (isDir); }