Package org.expath.pkg.repo

Examples of org.expath.pkg.repo.Package


        }
        catch (final URISyntaxException ex) {
            throw new XPathException("Invalid URI: " + namespace, ex);
        }
        for (final Packages pp : myParent.listPackages()) {
            final Package pkg = pp.latest();
            final ExistPkgInfo info = (ExistPkgInfo) pkg.getInfo("exist");
            if (info != null) {
                final String clazz = info.getJava(uri);
                if (clazz != null) {
                    return getModule(clazz, namespace, ctxt);
                }
View Full Code Here


            uri = new URI(namespace);
        } catch (final URISyntaxException ex) {
            throw new XPathException("Invalid URI: " + namespace, ex);
        }
        for (final Packages pp : myParent.listPackages()) {
            final Package pkg = pp.latest();
            // FIXME: Rely on having a file system storage, that's probably a bad design!
            final FileSystemResolver resolver = (FileSystemResolver) pkg.getResolver();
            final ExistPkgInfo info = (ExistPkgInfo) pkg.getInfo("exist");
            if (info != null) {
                final String f = info.getXQuery(uri);
                if (f != null) {
                    return resolver.resolveComponentAsFile(f);
                }
            }
            String sysid = null; // declared here to be used in catch
            try {
                final StreamSource src = pkg.resolve(namespace, URISpace.XQUERY);
                if (src != null) {
                    sysid = src.getSystemId();
                    return new File(new URI(sysid));
                }
            } catch (final URISyntaxException ex) {
View Full Code Here

    }

    public List<URI> getJavaModules() {
        final List<URI> modules = new ArrayList<URI>(13);
        for (final Packages pp : myParent.listPackages()) {
            final Package pkg = pp.latest();
            final ExistPkgInfo info = (ExistPkgInfo) pkg.getInfo("exist");
            if (info != null) {
                modules.addAll(info.getJavaModules());
            }
        }
        return modules;
View Full Code Here

                        LOG.debug("Package " + pkgName + " already installed");
                        Packages pkgs = repo.getParentRepo().getPackages(pkgName);
                        // check if installed package matches required version
                        if (pkgs != null) {
                            if (version != null) {
                                Package latest = pkgs.latest();
                                DependencyVersion depVersion = version.getDependencyVersion();
                                if (depVersion.isCompatible(latest.getVersion())) {
                                    isInstalled = true;
                                } else {
                                    LOG.debug("Package " + pkgName + " needs to be upgraded");
                                    if (enforceDeps) {
                                        throw new PackageException("Package requires version " + version.toString() +
                                            " of package " + pkgName +
                                            ". Installed version is " + latest.getVersion() + ". Please upgrade!");
                                    }
                                }
                            } else {
                                isInstalled = true;
                            }
View Full Code Here

        final File packageDir = getPackageDir(pkgName, repo);
        if (packageDir == null)
            // fails silently if package dir is not found?
            {return null;}
        final DocumentImpl repoXML = getRepoXML(packageDir);
        final Package pkg = getPackage(pkgName, repo);
        if (repoXML != null) {
            ElementImpl target = null;
            try {
                target = findElement(repoXML, TARGET_COLL_ELEMENT);
                final ElementImpl cleanup = findElement(repoXML, CLEANUP_ELEMENT);
View Full Code Here

                    }
                }
                if (targetCollection == null) {
                    // no target means: package does not need to be deployed into database
                    // however, we need to preserve a copy for backup purposes
                    final Package pkg = getPackage(pkgName, repo);
                    final String pkgColl = pkg.getAbbrev() + "-" + pkg.getVersion();
                    targetCollection = XmldbURI.SYSTEM.append("repo/" + pkgColl);
                }
                final ElementImpl permissions = findElement(repoXML, PERMISSIONS_ELEMENT);
                if (permissions != null) {
                    // get user, group and default permissions
View Full Code Here

     * @param pkgName
     * @param repo
     * @throws PackageException
     */
    private void cleanup(String pkgName, ExistRepository repo) throws PackageException {
        final Package pkg = getPackage(pkgName, repo);
        final String abbrev = pkg.getAbbrev();
        final File packageDir = getPackageDir(pkg);
        if (packageDir == null) {
            throw new PackageException("Cleanup: package dir for package " + pkgName + " not found");
        }
        File[] filesToDelete = packageDir.listFiles(new FileFilter() {
View Full Code Here

    private static void scanPackages(BrokerPool pool, Classpath classpath) {
        try {
            final ExistRepository repo = pool.getExpathRepo();
            for (final Packages pkgs : repo.getParentRepo().listPackages()) {
                final Package pkg = pkgs.latest();
                try {
                    final FileSystemStorage.FileSystemResolver resolver = (FileSystemStorage.FileSystemResolver) pkg.getResolver();
                    final File packageDir = resolver.resolveResourceAsFile(".");
                    scanPackageDir(classpath, packageDir);
                } catch (final IOException e) {
                    LOG.warn("An error occurred while updating classpath for package " + pkg.getName(), e);
                }
            }
        } catch (final Exception e) {
            LOG.warn("An error occurred while updating classpath for packages", e);
        }
View Full Code Here

    String path = args[1].getStringValue();
    try {
      File packageDir = null;
     
      ExistRepository repo = context.getRepository();
      Package pkg = null;
      for (Packages pp : repo.getParentRepo().listPackages()) {
        pkg = pp.latest();
        if (pkg.getName().equals(pkgName)) {
          try {
            StreamSource source = pkg.getResolver().resolveResource(path);
            return Base64BinaryDocument.getInstance(context, source.getInputStream());
          } catch (Storage.NotExistException ex) {
            // nothing
          }
        }
View Full Code Here

       
        ExistRepository repo = getContext().getRepository();
        Repository parent_repo = repo.getParentRepo();

        try {
            Package pkg;
            if (isCalledAs("install")) {
            // download .xar from a URI
            URI uri = _getURI(pkgOrPath);
                pkg = parent_repo.installPackage(uri, force, interact);
                repo.reportAction(ExistRepository.Action.INSTALL, pkg.getName());
          } else {
            // .xar is stored as a binary resource
            BinaryDocument doc = null;
            try {
              doc = _getDocument(pkgOrPath);
              File file = ((NativeBroker)context.getBroker()).getCollectionBinaryFileFsPath(doc.getURI());
              LOG.debug("Installing file: " + file.getAbsolutePath());
              pkg = parent_repo.installPackage(file, force, interact);
                    repo.reportAction(ExistRepository.Action.INSTALL, pkg.getName());
            } finally {
              if (doc != null)
                doc.getUpdateLock().release(Lock.READ_LOCK);
            }
          }
            ExistPkgInfo info = (ExistPkgInfo) pkg.getInfo("exist");
            if (info != null && !info.getJars().isEmpty())
                ClasspathHelper.updateClasspath(context.getBroker().getBrokerPool(), pkg);
            // TODO: expath libs do not provide a way to see if there were any XQuery modules installed at all
            context.getBroker().getBrokerPool().getXQueryPool().clear();
            removed = BooleanValue.TRUE;
View Full Code Here

TOP

Related Classes of org.expath.pkg.repo.Package

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.