public void addDocumentFilter(Object filter) throws PackageException { if (filter instanceof DocumentFilter) { this.documentFilters.add((DocumentFilter) filter); } else { throw new PackageException(PackageException.ERROR_PACKAGE_INVALID_FILTER, "Invalid Document Filter"); } }
public PackageAPI(Package plugin, XWikiContext context) throws PackageException { super(context); if (!hasAdminRights()) { throw new PackageException(XWikiException.ERROR_XWIKI_ACCESS_DENIED, "Admin right is needed to use this plugin"); } setPlugin(plugin); }
/** * 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 ""; }
throw new PackageException(XWikiException.ERROR_XWIKI_UNKNOWN, "document " + doc.getDocumentReference() + " does not exist in package definition");
throw new PackageException(XWikiException.ERROR_XWIKI_UNKNOWN, "Could not find the package definition"); throw new PackageException(XWikiException.ERROR_XWIKI_UNKNOWN, "Error when reading the XML");
public void addAllWikiDocuments(XWikiContext context) throws XWikiException { XWiki wiki = context.getWiki(); try { List<String> documentNames = wiki.getStore().getQueryManager().getNamedQuery("getAllDocuments").execute(); for (String docName : documentNames) { add(docName, DocumentInfo.ACTION_OVERWRITE, context); } } catch (QueryException ex) { throw new PackageException(PackageException.ERROR_XWIKI_STORE_HIBERNATE_SEARCH, "Cannot retrieve the list of documents to export", ex); } }