/** * Load document files from provided directory and sub-directories into packager. * * @param dir the directory from where to load documents. * @param context the XWiki context. * @return * @throws IOException error when loading documents. * @throws XWikiException error when loading documents. */ public String readFromDir(File dir, XWikiContext context) throws IOException, XWikiException { if (!dir.isDirectory()) { throw new PackageException(PackageException.ERROR_PACKAGE_UNKNOWN, dir.getAbsolutePath() + " is not a directory"); } int count = 0; try { File infofile = new File(dir, DefaultPackageFileName); Document description = fromXml(new FileInputStream(infofile)); count = readFromDir(dir, context, description); updateFileInfos(description); } catch (DocumentException e) { throw new PackageException(PackageException.ERROR_PACKAGE_UNKNOWN, "Error when reading the XML"); } LOG.info("Package read " + count + " documents"); return ""; }
count += readFromDir(file, context, description); } else { boolean validWikiDoc = false;