Package org.rhq.core.domain.content

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


            if (typeName == null) {
                throw new IllegalStateException("Missing the content source type name in details data");
            }

            ContentSource contentSource = synchronizeAndLoad(name, typeName);

            if (syncImportedRepos) {
                // Synchronize all repos associated with the content source - these may be repos we just
                // discovered during this sync or ones that were already associated.
                syncImportedRepos(contentSource);
View Full Code Here


        // has a very short session lifespan so we need to keep asking for a new one, due to the possibility
        // that some of the methods we call here take longer than the overlord's lifespan
        SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
        Subject overlord;
        ContentSourceManagerLocal contentManager = LookupUtil.getContentSourceManager();
        ContentSource contentSource;

        overlord = subjectManager.getOverlord();
        contentSource = contentManager
            .getContentSourceByNameAndType(overlord, contentSourceName, contentSourceTypeName);

        if (contentSource == null) {
            throw new Exception("Sync job was asked to sync an unknown content source: " + contentSourceName + "|"
                + contentSourceTypeName);
        }

        int contentSourceId = contentSource.getId();

        // If 'completed' is false, there was already a synchronization taking place,
        // so we should abort and let that already running sync take care of everything.
        boolean completed = contentManager.internalSynchronizeContentSource(contentSourceId);
View Full Code Here

        // append to this as we go along, building a status report
        StringBuilder progress = new StringBuilder();

        try {
            ContentSource contentSource = contentSourceManager.getContentSource(overlord, contentSourceId);
            if (contentSource == null) {
                throw new Exception("Cannot sync a non-existing content source [" + contentSourceId + "]");
            }

            // This should not take very long so it should be OK to block other
            // callers.
            // We are avoiding the problem that would occur if we try to
            // synchronize the same source
            // at the same time. We could do it more cleverly by synchronizing
            // on a per content source
            // basis, but I don't see a need right now to make this more
            // complicated.
            // We can come back and revisit if we need more fine-grained
            // locking.
            synchronized (synchronizeContentSourceLock) {
                progress.append(new Date()).append(": ");
                progress.append("Start synchronization of content source [").append(contentSource.getName()).append(
                    "]\n");
                progress.append(new Date()).append(": ");
                progress.append("Getting currently known list of packages...\n");
                results = new ContentSourceSyncResults(contentSource);
                results.setResults(progress.toString());
                results = contentSourceManager.persistContentSourceSyncResults(results);
            }

            if (results == null) {
                // note that it technically is still possible to have concurrent
                // syncs - if two
                // threads running in two different servers (i.e. different VMs)
                // both try to sync the
                // same content source and both enter the
                // persistContentSourceSyncResults method at
                // the same time, you'll get two inprogress rows - this is so
                // rare as to not care.
                // Even if it does happen, it may still work, or
                // one sync will get an error and rollback its tx and no harm
                // will be done.
                log.info("Content source [" + contentSource.getName()
                    + "] is already being synchronized - this sync request will be ignored.");
                return false;
            }

            RepoSourceSynchronizer repoSourceSynchronizer = new RepoSourceSynchronizer(contentSource, provider);
View Full Code Here

        ContentServerPluginContainer pc = ContentManagerHelper.getPluginContainer();
        Query q = entityManager.createNamedQuery(PackageVersionContentSource.QUERY_FIND_BY_CONTENT_SOURCE_ID_NO_FETCH);

        for (int id : contentSourceIds) {
            ContentSource contentSource = entityManager.find(ContentSource.class, id);
            if (contentSource == null) {
                throw new Exception("There is no content source with id [" + id + "]");
            }

            Set<ContentSource> alreadyAssociatedContentSources = repo.getContentSources();
            // Only add it if it's not already associated with this repo.
            if (!alreadyAssociatedContentSources.contains(contentSource)) {
                RepoContentSource repoContentSourceMapping = repo.addContentSource(contentSource);
                entityManager.persist(repoContentSourceMapping);
            }
            Set<PackageVersion> alreadyAssociatedPackageVersions = new HashSet<PackageVersion>(
                repo.getPackageVersions());

            // Automatically associate all of the content source's package versions with this repo,
            // but *skip* over the ones that are already linked to this repo from a previous association.
            q.setParameter("id", contentSource.getId());
            List<PackageVersionContentSource> pvcss = q.getResultList();
            for (PackageVersionContentSource pvcs : pvcss) {
                PackageVersion packageVersion = pvcs.getPackageVersionContentSourcePK().getPackageVersion();
                // Only add it if it's not already associated with this repo.
                if (!alreadyAssociatedPackageVersions.contains(packageVersion)) {
View Full Code Here

        if (repo == null) {
            throw new Exception("There is no repo with an ID [" + repoId + "]");
        }

        for (int id : contentSourceIds) {
            ContentSource cs = entityManager.find(ContentSource.class, id);
            if (cs == null) {
                throw new Exception("There is no content source with id [" + id + "]");
            }

            RepoContentSource ccsmapping = repo.addContentSource(cs);
View Full Code Here

        // If the user gets here trying to create a new content source, reset the previous object's data.
        // This is to prevent prepopulation of data from an earlier failed attempt if the user navigates off
        // the second attempt without using the cancel button.
        if ("new".equals(request.getParameter("mode"))) {
            newContentSource = new ContentSource();
            updateSelectedContentSourceType(this.selectedContentSourceType);
        }

        return newContentSource;
    }
View Full Code Here

    public String save() {
        Subject subject = EnterpriseFacesContextUtility.getSubject();
        ContentSourceManagerLocal manager = LookupUtil.getContentSourceManager();

        try {
            ContentSource created = manager.createContentSource(subject, newContentSource);
            FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Saved [" + created.getName()
                + "] with the ID of [" + created.getId() + "]");
        } catch (ContentException ce) {
            FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Error: " + ce.getMessage());
            return "edit"; // stay in edit mode upon failure
        }

        selectedContentSourceType = null;
        newContentSource = new ContentSource();

        return "save";
    }
View Full Code Here

        return "save";
    }

    public String cancel() {
        selectedContentSourceType = null;
        newContentSource = new ContentSource();
        return "cancel";
    }
View Full Code Here

                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);
View Full Code Here

                EntityManager entityManager = getEntityManager();

                // I just want to see this tested even though I haven't seen this fail on oracle or postgres ever
                ContentSourceType cst = new ContentSourceType("testLongVarCharCST");
                entityManager.persist(cst);
                ContentSource cs = new ContentSource("testLongVarCharCS", cst);
                cs.setLoadErrorMessage("longvarchar column here");
                entityManager.persist(cs);

                Query q = entityManager.createNamedQuery(ContentSource.QUERY_FIND_BY_ID_WITH_CONFIG);
                ContentSource result = (ContentSource) q.setParameter("id", cs.getId()).getSingleResult();
                assert result != null;
                assert "longvarchar column here".equals(result.getLoadErrorMessage());

            }
        });
    }
View Full Code Here

TOP

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

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.