Package org.rhq.core.domain.content

Examples of org.rhq.core.domain.content.Distribution


    public void createDeleteDistribution() throws Exception {

        String kslabel = "testCreateDeleteRepo";
        String kspath = "/tmp";
        int id = distManager.createDistribution(overlord, kslabel, kspath, distType).getId();
        Distribution distro = distManager.getDistributionByLabel(kslabel);

        assert distro != null;

        assert id == distro.getId();

        distManager.deleteDistributionByDistId(overlord, id);
        distro = distManager.getDistributionByLabel(kslabel);
        assert distro == null;
    }
View Full Code Here


        String kslabel = "testCreateDeleteRepo";
        String kspath = "/tmp";
        // don't get id, if not needed downstream
        //int id = distManager.createDistribution(overlord, kslabel, kspath, distType).getId();
        distManager.createDistribution(overlord, kslabel, kspath, distType);
        Distribution distro = distManager.getDistributionByLabel(kslabel);

        DistributionFile distfile = new DistributionFile(distro, "vmlinux", "d41d8cd98f00b204e9800998ecf8427e");
        em.persist(distfile);
        Query query = em.createNamedQuery(DistributionFile.SELECT_BY_DIST_ID);

        query.setParameter("distId", distro.getId());
        List<DistributionFile> results = query.getResultList();
        assert results.size() != 0;
        Query querydel = em.createNamedQuery(DistributionFile.DELETE_BY_DIST_ID);

        querydel.setParameter("distId", distro.getId());

        querydel.executeUpdate();

        List<DistributionFile> resultsdel = query.getResultList();
View Full Code Here

            log.info("TODO: create index.html listing all the distribution labels for this repo: " + repo.getName());
            renderDistributionLabels(request, response, repo);
            return;
        }
        // Get Distribution
        Distribution dist = distroMgr.getDistributionByLabel(distLabel);
        if (dist == null) {
            log.info("Unable to find Distribution by label '" + distLabel + "'");
            renderErrorPage(request, response);
            return;
        }
        String fileRequest = getDistFilePath(request.getRequestURI());
        if (StringUtils.isEmpty(fileRequest)) {
            log.info("no distribution file was found in request, so render list of all distribution files");
            renderDistributionFileList(request, response, dist);
            return;
        }
        log.debug("Parsed DistributionFile request is for: " + fileRequest);
        // Looks like a request for a distribution file
        List<DistributionFile> distFiles = distroMgr.getDistributionFilesByDistId(dist.getId());
        if (distFiles.isEmpty()) {
            log.info("Unable to find any distribution files for dist: " + dist.getLabel());
            renderErrorPage(request, response);
            return;
        }
        for (DistributionFile dFile : distFiles) {
            //log.info("Compare: " + dFile.getRelativeFilename() + " to " + fileRequest);
            if (StringUtils.equalsIgnoreCase(dFile.getRelativeFilename(), fileRequest)) {
                log.info("Sending back package bytes for: " + dFile.getRelativeFilename());

                writeDistributionFileBits(request, response, dFile);
                return;
            }
        }
        // This isn't a DistributionFile
        // This could be a request for a package.  Package requests will come in as:
        // ..../distributions/{Server,Cluster,Packages,etc}/a2ps-XXXXX.rpm 

        String possiblePkgName = getLastPiece(request.getRequestURI());
        log.debug("Looking up : " + possiblePkgName + ", it might be a package request");
        PackageVersion pv = getPackageVersionFromFileName(repo, possiblePkgName);
        if (pv != null) {
            log.info(possiblePkgName + " resolved to a package, will send package bytes back as response");
            //response.setContentType("application/octet-stream");
            writePackageVersionBits(request, response, pv);
            return;
        }
        log.info("Searched through DistributionFiles and Packages, unable to find: " + fileRequest
            + ", in Distribution: " + dist.getLabel());

        renderErrorPage(request, response);

    }
View Full Code Here

        DistributionManagerLocal distManager = LookupUtil.getDistributionManagerLocal();
        Subject overlord = LookupUtil.getSubjectManager().getOverlord();

        // remove all distributions that are no longer available on the remote repository
        for (DistributionDetails doomedDetails : report.getDeletedDistributions()) {
            Distribution doomedDist = distManager.getDistributionByLabel(doomedDetails.getLabel());
            distManager.deleteDistributionByDistId(overlord, doomedDist.getId());
            distManager.deleteDistributionFilesByDistId(overlord, doomedDist.getId());
            progress.append("Removed distribution & distribution files for: " + doomedDetails.getLabel());
            syncResults.setResults(progress.toString());
            syncResults = repoManager.mergeRepoSyncResults(syncResults);
        }
View Full Code Here

        for (DistributionDetails detail : newDetails) {
            try {

                log.debug("Attempting to create new distribution based off of: " + detail);
                DistributionType distType = distManager.getDistributionTypeByName(detail.getDistributionType());
                Distribution newDist = distManager.createDistribution(overlord, detail.getLabel(), detail
                    .getDistributionPath(), distType);
                log.debug("Created new distribution: " + newDist);
                Repo repo = repoManager.getRepo(overlord, report.getRepoId());
                RepoDistribution repoDist = new RepoDistribution(repo, newDist);
                log.debug("Created new mapping of RepoDistribution repoId = " + repo.getId() + ", distId = "
                    + newDist.getId());
                entityManager.persist(repoDist);
                List<DistributionFileDetails> files = detail.getFiles();
                for (DistributionFileDetails f : files) {
                    log.debug("Creating DistributionFile for: " + f);
                    DistributionFile df = new DistributionFile(newDist, f.getRelativeFilename(), f.getMd5sum());
View Full Code Here

    public long outputDistributionFileBits(DistributionFile distFile, OutputStream outputStream) {

        long numBytes = 0L;
        InputStream bitStream = null;
        try {
            Distribution dist = distFile.getDistribution();
            log.info("Distribution has a basePath of " + dist.getBasePath());
            String distFilePath = dist.getBasePath() + "/" + distFile.getRelativeFilename();
            File f = getDistributionFileBitsLocalFilesystemFile(dist.getLabel(), distFilePath);
            log.info("Fetching: " + distFilePath + " on local file store from: " + f.getAbsolutePath());
            bitStream = new FileInputStream(f);
            numBytes = StreamUtil.copy(bitStream, outputStream);

        } catch (Exception e) {
View Full Code Here

        DistributionType loaded = distributionManager.getDistributionTypeByName(disttype.getName());
        if (loaded != null) {
            disttype = loaded;
        }

        Distribution kstree = new Distribution(kslabel, basepath, disttype);

        validateDistTree(kstree);
        entityManager.persist(kstree);

        return kstree;
View Full Code Here

        entityManager.clear();

        entityManager.createNamedQuery(Distribution.QUERY_DELETE_BY_DIST_ID).setParameter("distid", distId)
            .executeUpdate();

        Distribution kstree = entityManager.find(Distribution.class, distId);
        if (kstree != null) {
            entityManager.remove(kstree);
            log.debug("User [" + user + "] deleted kstree [" + kstree + "]");
        } else {
            log.debug("Distribution tree ID [" + distId + "] doesn't exist - nothing to delete");
View Full Code Here

        if (kstree.getLabel() == null || kstree.getLabel().trim().equals("")) {
            throw new DistributionException("A valid Distribution tree is required");
        }

        Distribution kstreeobj = getDistributionByLabel(kstree.getLabel());
        if (kstreeobj != null) {
            throw new DistributionException("There is already a kstree with the name of [" + kstree.getLabel() + "]");
        }

    }
View Full Code Here

            // Delete all distributions
            distroManager.deleteDistributionMappingsForRepo(overlord, repoToSync.getId());

            for (String distroLabel : TestContentProvider.DISTRIBUTIONS.keySet()) {
                Distribution distro = distroManager.getDistributionByLabel(distroLabel);
                if (distro != null) {
                    // Delete the files
                    query = entityManager.createNamedQuery(DistributionFile.DELETE_BY_DIST_ID);
                    query.setParameter("distId", distro.getId());
                    query.executeUpdate();

                    // Delete the actual distro
                    distroManager.deleteDistributionByDistId(overlord, distro.getId());
                }
            }

            // Delete all package version <-> content source mappings
            for (ContentSource source : repoContentSources) {
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.content.Distribution

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.