Package org.rhq.enterprise.server.content

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


        }

        @Override
        public PageList<ContentSource> fetchPage(PageControl pc) {
            Subject subject = EnterpriseFacesContextUtility.getSubject();
            ContentSourceManagerLocal manager = LookupUtil.getContentSourceManager();

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


        return "edit";
    }

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

        try {
            manager.updateContentSource(subject, contentSource, true);
            FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "The content source ["
                + contentSource.getName() + "] has been updated.");
        } catch (Exception e) {
            FacesContextUtility.addMessage(FacesMessage.SEVERITY_WARN, "Failed to update content source ["
                + contentSource.getName() + "]", e);
View Full Code Here

    public String cancel() {
        return "success";
    }

    public String test() {
        ContentSourceManagerLocal manager = LookupUtil.getContentSourceManager();

        try {
            manager.testContentSourceConnection(this.contentSource.getId());
            FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
                    "Test passed - the remote repository for [" + this.contentSource.getName() + "] is available.");
        } catch (Exception e) {
            FacesContextUtility.addMessage(FacesMessage.SEVERITY_WARN,
                    "Test failed - failed to connect to the remote repository for [" + this.contentSource.getName()
View Full Code Here

        return "success";
    }

    public String sync() {
        // Test the content source connection before proceeding.
        ContentSourceManagerLocal contentSourceManager = LookupUtil.getContentSourceManager();
        try {
            contentSourceManager.testContentSourceConnection(this.contentSource.getId());
        } catch (Exception e) {
            FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR,
                    "Failed to connect to the remote repository for [" + this.contentSource.getName()
                        + "] - check the configuration and make sure the remote repository is up and reachable. Details: "
                        + ThrowableUtil.getAllMessages(e));
            return "success";
        }

        Subject subject = EnterpriseFacesContextUtility.getSubject();
        try {
            contentSourceManager.synchronizeAndLoadContentSource(subject, this.contentSource.getId());
            FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Synchronizing content source ["
                + this.contentSource.getName() + "] now.");
        } catch (Exception e) {
            FacesContextUtility.addMessage(FacesMessage.SEVERITY_WARN,
                "Failed to start the synchronization process for [" + this.contentSource.getName() + "]", e);
View Full Code Here

    private void loadContentSource() {
        Integer id = FacesContextUtility.getRequiredRequestParameter("id", Integer.class);
        if (this.contentSource == null || (this.contentSource != null && this.contentSource.getId() != id)) {
            Subject subject = EnterpriseFacesContextUtility.getSubject();
            ContentSourceManagerLocal manager = LookupUtil.getContentSourceManager();
            this.contentSource = manager.getContentSource(subject, id);

            // make sure we load the full CST including the config def
            String cstName = this.contentSource.getContentSourceType().getName();
            this.contentSource.setContentSourceType(manager.getContentSourceType(cstName));

            ConfigurationUtility.normalizeConfiguration(this.contentSource.getConfiguration(), this.contentSource
                .getContentSourceType().getContentSourceConfigurationDefinition());
        }
    }
View Full Code Here

        String[] selected = getSelectedContentSourceSyncResults();
        int[] ids = getIntegerArray(selected);

        if ((ids != null) && (ids.length > 0)) {
            try {
                ContentSourceManagerLocal contentSourceManager = LookupUtil.getContentSourceManager();
                contentSourceManager.deleteContentSourceSyncResults(subject, ids);

                FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Deleted [" + ids.length
                    + "] content source sync results.");
            } catch (Exception e) {
                FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR,
View Full Code Here

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

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

        return "Content source has an empty configuration."; // is this ever really used?
    }

    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
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 "
                    + packageId
                    + " either doesn't exist at all or doesn't have any version. Can't execute a CLI script without a script to run.");
        }

        PipedInputStream bits = new PipedInputStream();
        final PipedOutputStream out = new PipedOutputStream(bits);

        Thread reader = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    csm.outputPackageVersionBits(versionToUse, out);
                } catch (RuntimeException e) {
                    LOG.warn("The thread for reading the bits of package version [" + versionToUse
                        + "] failed with exception.", e);
                    throw e;
                } finally {
View Full Code Here

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

TOP

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

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.