コード例 #1
0
ファイル: PkgValidator.java プロジェクト: bhuesemann/basex
 /**
  * Checks package descriptor and if packages involved in dependencies are already installed.
  *
  * @param pkg package
  * @throws QueryException query exception
  */
 public void check(final Package pkg) throws QueryException {
   // check if package is already installed
   final byte[] name = pkg.uniqueName();
   if (repo.pkgDict().get(name) != null) PKGINST.thrw(input, name);
   // check package dependencies
   checkDepends(pkg);
   // check package components
   checkComps(pkg);
 }
コード例 #2
0
ファイル: PkgValidator.java プロジェクト: bhuesemann/basex
  /**
   * Checks if an XQuery component is already installed as part of another package.
   *
   * @param comp component
   * @param name component's package
   * @return result
   * @throws QueryException query exception
   */
  private boolean isInstalled(final Component comp, final byte[] name) throws QueryException {
    // get packages in which the module's namespace is found
    final TokenSet pkgs = repo.nsDict().get(comp.uri);
    if (pkgs == null) return false;

    for (final byte[] nextPkg : pkgs) {
      if (nextPkg != null && !eq(Package.name(nextPkg), name)) {
        // installed package is a different one, not just a different version
        // of the current one
        final String pkgDir = string(repo.pkgDict().get(nextPkg));
        final IO pkgDesc = new IOFile(repo.path(pkgDir), DESCRIPTOR);
        final Package pkg = new PkgParser(repo, input).parse(pkgDesc);
        for (final Component nextComp : pkg.comps) {
          if (nextComp.name().equals(comp.name())) return true;
        }
      }
    }
    return false;
  }