Package org.rhq.enterprise.server.content

Examples of org.rhq.enterprise.server.content.RepoManagerLocal


        }

        @Override
        public PageList<Repo> fetchPage(PageControl pc) {
            Subject subject = EnterpriseFacesContextUtility.getSubject();
            RepoManagerLocal manager = LookupUtil.getRepoManagerLocal();

            PageList<Repo> results = manager.findRepos(subject, pc);
            for (Repo repo : results) {
                repo.setSyncStatus(manager.calculateSyncStatus(subject, repo.getId()));
            }
            return results;
        }
View Full Code Here


        int repoId = Integer.valueOf(FacesContextUtility.getRequiredRequestParameter("id"));
        int[] contentSourceIds = getIntegerArray(selected);

        if ((contentSourceIds != null) && (contentSourceIds.length > 0)) {
            try {
                RepoManagerLocal manager = LookupUtil.getRepoManagerLocal();
                manager.removeContentSourcesFromRepo(subject, repoId, contentSourceIds);

                FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Disassociated [" + contentSourceIds.length
                    + "] content sources from repository");
            } catch (Exception e) {
                FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR,
View Full Code Here

        @Override
        public PageList<ContentSource> fetchPage(PageControl pc) {
            Subject subject = EnterpriseFacesContextUtility.getSubject();
            int id = Integer.valueOf(FacesContextUtility.getRequiredRequestParameter("id"));
            RepoManagerLocal manager = LookupUtil.getRepoManagerLocal();

            PageList<ContentSource> results = manager.findAssociatedContentSources(subject, id, pc);
            return results;
        }
View Full Code Here

        int repoId = Integer.valueOf(FacesContextUtility.getRequiredRequestParameter("id"));
        int[] contentSourceIds = getIntegerArray(selected);

        if ((contentSourceIds != null) && (contentSourceIds.length > 0)) {
            try {
                RepoManagerLocal manager = LookupUtil.getRepoManagerLocal();
                manager.removeContentSourcesFromRepo(subject, repoId, contentSourceIds);

                FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Disassociated [" + contentSourceIds.length
                    + "] content sources from repository");
            } catch (Exception e) {
                FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR,
View Full Code Here

        @Override
        public PageList<ContentSource> fetchPage(PageControl pc) {
            Subject subject = EnterpriseFacesContextUtility.getSubject();
            int id = Integer.valueOf(FacesContextUtility.getRequiredRequestParameter("id"));
            RepoManagerLocal manager = LookupUtil.getRepoManagerLocal();

            PageList<ContentSource> results = manager.findAssociatedContentSources(subject, id, pc);
            return results;
        }
View Full Code Here

        final int repoPageSize = 10;
        final int distroPageSize = 10;

        Map<Repo, Map<String, Distribution>> reposDistros = new HashMap<Repo, Map<String, Distribution>>();

        RepoManagerLocal repoMgr = LookupUtil.getRepoManagerLocal();
        PageControl repoPC = new PageControl(0, repoPageSize);
        int totalReposProcessed = 0;
        while (true) {
            PageList<Repo> repoPage = repoMgr.findRepos(LookupUtil.getSubjectManager().getOverlord(), repoPC);

            if (repoPage.size() <= 0) {
                break;
            }

            for (Repo repoPageItem : repoPage) {
                if (!repoPageItem.isCandidate()) {
                    Map<String, Distribution> distrosMap = reposDistros.get(repoPageItem);
                    if (distrosMap == null) {
                        distrosMap = new HashMap<String, Distribution>();
                        reposDistros.put(repoPageItem, distrosMap);
                    }

                    PageControl distroPC = new PageControl(0, distroPageSize);
                    int totalDistrosProcessed = 0;
                    while (true) {
                        PageList<Distribution> distroPage = repoMgr.findAssociatedDistributions(LookupUtil
                            .getSubjectManager().getOverlord(), repoPageItem.getId(), distroPC);
                        if (distroPage.size() <= 0) {
                            break;
                        }
                        for (Distribution distroPageItem : distroPage) {
View Full Code Here

        return engine;
    }

    private static BitsAndFileExtension getPackageBits(int packageId, int repoId) throws IOException {
        final ContentSourceManagerLocal csm = LookupUtil.getContentSourceManager();
        RepoManagerLocal rm = LookupUtil.getRepoManagerLocal();
        final PackageVersion versionToUse = rm.getLatestPackageVersion(LookupUtil.getSubjectManager().getOverlord(),
            packageId, repoId);

        if (versionToUse == null) {
            throw new IllegalArgumentException(
                "The package with id "
View Full Code Here

            ret = ret.replace("$userName", config.subject.getName());

            //now get the package and repo info
            Subject overlord = LookupUtil.getSubjectManager().getOverlord();
            RepoManagerLocal rm = LookupUtil.getRepoManagerLocal();
            PackageVersion versionToUse = rm.getLatestPackageVersion(overlord, config.packageId, config.repoId);

            if (versionToUse != null) {
                ret = ret.replace("$packageName", versionToUse.getDisplayName());
                ret = ret.replace(
                    "$packageVersion",
                    versionToUse.getDisplayVersion() == null ? versionToUse.getVersion() : versionToUse
                        .getDisplayVersion());
            } else {
                ret = ret.replace("$packageName", "unknown script with package id " + config.packageId);
                ret = ret.replace("$packageVersion", "no version");
            }

            RepoCriteria criteria = new RepoCriteria();
            criteria.addFilterId(config.repoId);
            criteria.clearPaging();//disable paging as the code assumes all the results will be returned.

            List<Repo> repos = rm.findReposByCriteria(overlord, criteria);

            String repoName;

            if (repos.size() > 0) {
                repoName = repos.get(0).getName();
View Full Code Here

            tx.begin();
            EntityManager entityManager = getEntityManager();

            ContentManagerLocal contentManager = LookupUtil.getContentManager();
            ContentSourceManagerLocal contentSourceManager = LookupUtil.getContentSourceManager();
            RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
            ResourceTypeManagerLocal resourceTypeManager = LookupUtil.getResourceTypeManager();
            SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
            Subject overlord = subjectManager.getOverlord();

            // protect if it aleady exists due to a failed run
            contentSourceType = contentSourceManager.getContentSourceType("testType");
            if (null == contentSourceType) {
                // Create a sample content source type that will be used in this test
                contentSourceType = new ContentSourceType("testType");
                entityManager.persist(contentSourceType);
                entityManager.flush();
            }

            // protect if it aleady exists due to a failed run
            ContentSource cs1 = contentSourceManager.getContentSourceByNameAndType(overlord, "contentSource1",
                "testType");
            if (null == cs1) {
                // A repo sync will query all providers for that repo, so add multiple providers
                cs1 = new ContentSource("contentSource1", contentSourceType);
                cs1.setDownloadMode(DownloadMode.DATABASE);
                cs1 = contentSourceManager.simpleCreateContentSource(overlord, cs1);
            }
            ContentSource cs2 = contentSourceManager.getContentSourceByNameAndType(overlord, "contentSource2",
                "testType");
            if (null == cs2) {
                cs2 = new ContentSource("contentSource2", contentSourceType);
                cs2.setDownloadMode(DownloadMode.DATABASE);
                cs2 = contentSourceManager.simpleCreateContentSource(overlord, cs2);
            }

            pluginService.associateContentProvider(cs1, contentProvider1);
            pluginService.associateContentProvider(cs2, contentProvider2);

            repoContentSources.add(cs1);
            repoContentSources.add(cs2);

            // Create the package type packages will be created against
            resourceType = resourceTypeManager.getResourceTypeByNameAndPlugin(TestContentProvider.RESOURCE_TYPE_NAME,
                TestContentProvider.RESOURCE_TYPE_PLUGIN_NAME);
            if (null == resourceType) {
                resourceType = new ResourceType(TestContentProvider.RESOURCE_TYPE_NAME,
                    TestContentProvider.RESOURCE_TYPE_PLUGIN_NAME, ResourceCategory.PLATFORM, null);
                entityManager.persist(resourceType);
                entityManager.flush();
            }

            List<PackageType> packageTypes = contentManager.findPackageTypes(overlord,
                TestContentProvider.RESOURCE_TYPE_NAME, TestContentProvider.RESOURCE_TYPE_PLUGIN_NAME);
            if (!packageTypes.isEmpty()) {
                packageType = packageTypes.get(0);
            } else {
                packageType = new PackageType(TestContentProvider.PACKAGE_TYPE_NAME, resourceType);
                entityManager.persist(packageType);
            }

            // Create the repo to be synced
            List<Repo> repos = repoManager.getRepoByName(TestContentProvider.REPO_WITH_PACKAGES);
            if (!repos.isEmpty()) {
                repoToSync = repos.get(0);
            } else {
                Repo repo = new Repo(TestContentProvider.REPO_WITH_PACKAGES);
                repo.addContentSource(cs1);
                //        repo.addContentSource(cs2);  Disabled until we implement a second test content source to return new stuff
                repoToSync = repoManager.createRepo(overlord, repo);
            }

            tx.commit();
        } catch (Throwable t) {
            tx.rollback();
View Full Code Here

            EntityManager entityManager = getEntityManager();

            Query query;

            ContentSourceManagerLocal contentSourceManagerLocal = LookupUtil.getContentSourceManager();
            RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
            DistributionManagerLocal distroManager = LookupUtil.getDistributionManagerLocal();
            SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
            Subject overlord = subjectManager.getOverlord();

            // 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) {
                contentSourceManagerLocal.deleteContentSource(overlord, source.getId());
            }
            repoContentSources.clear();

            // Delete the repo
            repoManager.deleteRepo(overlord, repoToSync.getId());

            // Delete any packages that were created
            for (ContentProviderPackageDetails details : TestContentProvider.PACKAGES.values()) {
                String packageName = details.getContentProviderPackageDetailsKey().getName();
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.content.RepoManagerLocal

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.