Package org.rhq.core.domain.content

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


                ContentSource source2 = new ContentSource("testSource2", contentSourceType);
                source2 = contentSourceManager.simpleCreateContentSource(overlord, source2);

                // -> Only has source to delete, should be deleted
                Repo repo1 = new Repo("repo1");
                repo1.setCandidate(true);
                repo1.addContentSource(source1);

                // -> Has different source, should not be deleted
                Repo repo2 = new Repo("repo2");
                repo2.setCandidate(true);
                repo2.addContentSource(source2);

                // -> Has source to delete and another source, should not be deleted
                Repo repo3 = new Repo("repo3");
                repo3.setCandidate(true);
                repo3.addContentSource(source1);
                repo3.addContentSource(source2);

                // -> No sources, should not be deleted
                Repo repo4 = new Repo("repo4");
                repo4.setCandidate(true);

                repo1 = repoManager.createRepo(overlord, repo1);
                repo2 = repoManager.createRepo(overlord, repo2);
                repo3 = repoManager.createRepo(overlord, repo3);
                repo4 = repoManager.createRepo(overlord, repo4);

                // Test
                repoManager.deleteCandidatesWithOnlyContentSource(overlord, source1.getId());

                // Verify
                assert repoManager.getRepo(overlord, repo1.getId()) == null;
                assert repoManager.getRepo(overlord, repo2.getId()) != null;
                assert repoManager.getRepo(overlord, repo3.getId()) != null;
                assert repoManager.getRepo(overlord, repo4.getId()) != null;
            }
        });
    }
View Full Code Here


                contentSourceMetadataManager.registerTypes(types);

                ContentSource source = new ContentSource("testSource1", contentSourceType);
                source = contentSourceManager.simpleCreateContentSource(overlord, source);

                Repo repo = new Repo(oldName);
                repo = repoManager.createRepo(overlord, repo);

                repoManager.simpleAddContentSourcesToRepo(overlord, repo.getId(), new int[] { source.getId() });

                // Test
                repo.setName(newName);
                repoManager.updateRepo(overlord, repo);

                // Verify
                RepoCriteria byName = new RepoCriteria();
                byName.addFilterName(newName);
View Full Code Here

    public void updateSyncSchedule() {
        executeInTransaction(new TransactionCallback() {

            public void execute() throws Exception {

                Repo repo = new Repo("updateSyncSchedule");
                repo.setSyncSchedule("NOT A VALID CRON");
                boolean failed = false;
                try {
                    repo = repoManager.createRepo(overlord, repo);
                } catch (RepoException e) {
                    failed = true;
                }
                assert failed;

                failed = false;
                repo.setSyncSchedule("0 0 3 * * ?");
                try {
                    repo = repoManager.createRepo(overlord, repo);
                } catch (RepoException e) {
                    failed = true;
                }
View Full Code Here

            package4.addVersion(packageVersion4);

            em.persist(package4);

            // Wire up the repo to the resource and add all of these packages to it
            repo1 = new Repo("repo-" + RandomStringUtils.randomNumeric(6));
            em.persist(repo1);

            repoPackageVersion1 = repo1.addPackageVersion(packageVersion1);
            repoPackageVersion2 = repo1.addPackageVersion(packageVersion2);
            repoPackageVersion3 = repo1.addPackageVersion(packageVersion3);
            repoPackageVersion4 = repo1.addPackageVersion(packageVersion4);

            em.persist(repoPackageVersion1);
            em.persist(repoPackageVersion2);
            em.persist(repoPackageVersion3);
            em.persist(repoPackageVersion4);

            resourceRepo1 = repo1.addResource(resource);
            em.persist(resourceRepo1);

            // Subscribe the resource to a second repo to make sure the joins won't duplicate stuff
            repo2 = new Repo("test-" + RandomStringUtils.randomNumeric(6));
            em.persist(repo2);

            resourceRepo2 = repo2.addResource(resource);
            em.persist(resourceRepo2);
View Full Code Here

            contentSource.setDownloadMode(DownloadMode.DATABASE);
            contentSource = contentSourceManager.simpleCreateContentSource(overlord, contentSource);
            contentSourceId = contentSource.getId();
            assert contentSourceId > 0;

            Repo repo = new Repo("testMergeSyncReportAMU2Ch");
            repo = repoManager.createRepo(overlord, repo);
            repoId = repo.getId();
            assert repoId > 0;
            repoManager.addContentSourcesToRepo(overlord, repoId, new int[] { contentSourceId });

            // just make sure there are no package versions yet
            assert 0 == contentSourceManager.getPackageVersionCountFromContentSource(overlord, contentSourceId);
View Full Code Here

            // test the getAll API
            assert (csCount + 1) == contentSourceManager.getAllContentSources(overlord, pc).size();

            // create a repo and associate the new content source with it
            Repo repo = new Repo("testDel-" + RandomStringUtils.randomAlphanumeric(6));
            repoManager.createRepo(overlord, repo);
            repoManager.addContentSourcesToRepo(overlord, repo.getId(), new int[] { contentSourceId });

            // try to delete the content source
            assert null != contentSourceManager.getContentSource(overlord, contentSourceId) : "should exist";
            contentSourceManager.deleteContentSource(overlord, contentSourceId);
            assert null == contentSourceManager.getContentSource(overlord, contentSourceId) : "should have been deleted";

            // I need to clean these up now
            repoManager.deleteRepo(overlord, repo.getId());
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        } finally {
            contentSourceMetadataManager.registerTypes(new HashSet<ContentSourceType>());
View Full Code Here

            assert contentSource != null;
            int contentSourceId = contentSource.getId();
            assert contentSourceId > 0;

            // create a repo and associate the new content source with it
            Repo repo = new Repo("testMergeWithRepo");
            repo = repoManager.createRepo(overlord, repo);
            repoManager.addContentSourcesToRepo(overlord, repo.getId(), new int[] { contentSourceId });

            // this report will add a mapping to PV->CS
            // we didn't set up any mappings like that yet - this will be the first one
            // since a repo has this CS - the repo->PV will also get mapped
            PackageSyncReport report = new PackageSyncReport();
            ContentProviderPackageDetailsKey key = new ContentProviderPackageDetailsKey("testMergeWithRepofoo",
                "testMergeWithRepo-Version", packageType1.getName(), architecture1.getName(), resourceType1.getName(),
                resourceType1.getPlugin());
            ContentProviderPackageDetails details = new ContentProviderPackageDetails(key);
            details.setExtraProperties(new Configuration());
            details.getExtraProperties().put(new PropertySimple("hello", "world"));
            details.setLocation("dummy-location");
            details.setFileSize(0L); // under the covers this ends up allowing us to create a package bits of size 0
            report.addNewPackage(details);
            Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous;
            previous = new HashMap<ContentProviderPackageDetailsKey, PackageVersionContentSource>();

            RepoSyncResults results = new RepoSyncResults(repo);
            results = repoManager.persistRepoSyncResults(results);
            assert results != null;

            contentSourceManager.mergePackageSyncReport(contentSource, repo, report, previous, results);

            List<PackageVersion> inRepo;
            inRepo = repoManager.findPackageVersionsInRepo(overlord, repo.getId(), PageControl.getUnlimitedInstance());
            assert inRepo != null;
            assert inRepo.size() == 1;
            assert "testMergeWithRepo-Version".equals(inRepo.get(0).getVersion());

            // sanity check - make sure our own entity manager can find the PV entity
            getTransactionManager().begin();
            try {
                PackageVersion foundPv = getEntityManager().find(PackageVersion.class, inRepo.get(0).getId());
                assert foundPv != null;
                assert foundPv.getExtraProperties() != null;
                assert foundPv.getExtraProperties().getSimple("hello").getStringValue().equals("world");
            } finally {
                getTransactionManager().rollback();
            }

            // delete the content source first
            contentSourceManager.deleteContentSource(overlord, contentSourceId);

            // make sure our PV isn't orphaned yet! It is directly related to the repo still
            getTransactionManager().begin();
            try {
                assert null != getEntityManager().find(PackageVersion.class, inRepo.get(0).getId());
            } finally {
                getTransactionManager().rollback();
            }

            // delete the repo - this finally orphans the PV, so the PV should get deleted automatically
            repoManager.deleteRepo(overlord, repo.getId());

            // test to make sure we purged the orphaned package version (since both content source and repo are gone now)
            getTransactionManager().begin();
            try {
                assert null == getEntityManager().find(PackageVersion.class, inRepo.get(0).getId());
View Full Code Here

        assertNotNull(b.getBundleVersions());
        assertEquals(1, b.getBundleVersions().size());
        BundleVersion bv = b.getBundleVersions().get(0);
        assertEquals(bv2, bv);
        assertEquals(b, bv.getBundle());
        Repo r = b.getRepo();
        assertNotNull(r);
        assertEquals(b.getName(), r.getName());
    }
View Full Code Here

            // defer back to DefaultServlet.doGet and this will be served automatically
            super.doGet(request, response);
            return;
        }
        // Check if repo has been specified
        Repo repo = getRepo(request, response);
        if (repo == null) {
            log.info("No repo found, possibly bad repo name, or no name was entered.");
            renderRepoList(request, response);
            return;
        }

        // validate entitlement
        try {
            ContentFilter x509Filter = new ContentFilter();
            x509Filter.filter(request, repo.getId());
        } catch (EntitlementException e) {
            throw new ServletException(e);
        }

        // Check if type of content has been specified
View Full Code Here

        if (repoList.size() != 1) {
            throw new RuntimeException("Unexpected number of repos found for name [" + repoName + "]. " + "Found ["
                + repoList.size() + "] repos");
        }
        Repo repoToSync = repoList.get(0);

        // This call executes all of the logic associated with synchronizing the given repo
        repoManager.internalSynchronizeRepos(overlord, new Integer[] { repoToSync.getId() });
    }
View Full Code Here

TOP

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

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.