Package org.rhq.enterprise.server.content

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


        return OUTCOME_CANCEL;
    }

    public SelectItem[] getArchitectures() {
        Subject subject = EnterpriseFacesContextUtility.getSubject();
        ContentManagerLocal contentManager = LookupUtil.getContentManager();
        List<Architecture> architectures = contentManager.findArchitectures(subject);

        SelectItem[] items = new SelectItem[architectures.size()];
        int itemCounter = 0;
        for (Architecture arch : architectures) {
            SelectItem item = new SelectItem(arch.getId(), arch.getName());
View Full Code Here


    private PackageType lookupPackageType() {
        if (resourceType == null) {
            resourceType = lookupResourceType();
        }
        ContentManagerLocal contentManager = LookupUtil.getContentManager();
        PackageType packageType = contentManager.getResourceCreationPackageType(this.resourceType.getId());
        return packageType;
    }
View Full Code Here

        // Collect the necessary information
        Subject subject = EnterpriseFacesContextUtility.getSubject();
        Resource resource = EnterpriseFacesContextUtility.getResource();

        // Send the request to the bean
        ContentManagerLocal contentManager = LookupUtil.getContentManager();

        try {
            contentManager.retrieveBitsFromResource(subject, resource.getId(), selectedInstalledPackage);
        } catch (Exception e) {
            String errorMessages = ThrowableUtil.getAllMessages(e);
            FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR,
                "Failed to send retrieve content request to the agent. Cause: " + errorMessages);
            return "successOrFailure";
View Full Code Here

        }
    }

    private PackageType ensurePackageTypeExists(PackageTypeDefinitionType def) throws InvalidPluginDescriptorException {
        SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
        ContentManagerLocal cm = LookupUtil.getContentManager();

        PackageType packageType = cm.findPackageType(subjectManager.getOverlord(), null, def.getName());

        if (packageType == null) {
            //TODO support tying the package type to the resource types?
            packageType = new PackageType(def.getName(), null);
            packageType.setDescription(def.getDescription());
            packageType.setDisplayName(def.getDisplayName());
            packageType.setSupportsArchitecture(def.isSupportsArchitecture());
            packageType.setCreationData(false);
            packageType.setDeploymentConfigurationDefinition(ConfigurationMetadataParser.parse(def.getName(),
                def.getConfiguration()));
            packageType.setDiscoveryInterval(-1);
            packageType.setPackageExtraPropertiesDefinition(null);

            packageType = cm.persistServersidePackageType(packageType);
        }

        return packageType;
    }
View Full Code Here

    }

    public PackageType getScriptPackageType() {
        if (packageType == null) {
            SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
            ContentManagerLocal cm = LookupUtil.getContentManager();
            packageType = cm.findPackageType(subjectManager.getOverlord(), null, PACKAGE_TYPE_NAME);
        }
        return packageType;
    }
View Full Code Here

    }

    private List<AlertNotification> getCliNotificationsWithInvalidPackage(List<AlertNotification> allNotifications) {
        List<AlertNotification> ret = new ArrayList<AlertNotification>();

        ContentManagerLocal contentManager = LookupUtil.getContentManager();
        SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();

        Subject overlord = subjectManager.getOverlord();

        PackageVersionCriteria crit = new PackageVersionCriteria();
        crit.setRestriction(Restriction.COUNT_ONLY);

        for (AlertNotification cliNotification : allNotifications) {

            int count = 0;

            String packageId = cliNotification.getConfiguration().getSimpleValue(CliSender.PROP_PACKAGE_ID, null);
            if (packageId != null) {
                crit.addFilterPackageId(Integer.valueOf(packageId));

                PageList<PackageVersion> res = contentManager.findPackageVersionsByCriteria(overlord, crit);
                count = res.getTotalSize();
            }

            if (count == 0) {
                ret.add(cliNotification);
View Full Code Here

        when(ContentManagerHelper.getPackageTypeBehavior(1)).thenReturn(mockPackageTypeBehavior);

        when(mockEntityManager.createNamedQuery(eq(Architecture.QUERY_FIND_BY_NAME))).thenReturn(mockQuery);
        when(mockEntityManager.createNamedQuery(eq(Package.QUERY_FIND_BY_NAME_PKG_TYPE_ID))).thenReturn(mockQuery);

        ContentManagerLocal mockContentManager = mock(ContentManagerLocal.class);
        Package mockPackage = mock(Package.class);
        when(mockContentManager.persistPackage(isNotNull(Package.class))).thenReturn(mockPackage);
       
        when(mockEntityManager.find(eq(Package.class), any())).thenReturn(mockPackage);
        when(mockPackage.getPackageType()).thenReturn(mockPackageType);

        PackageVersion mockPackageVersion = mock(PackageVersion.class);
        when(mockContentManager.persistPackageVersion(isNotNull(PackageVersion.class)))
            .thenReturn(mockPackageVersion);

        when(mockEntityManager.find(eq(PackageVersion.class), anyInt())).thenReturn(mockPackageVersion);
        when(mockPackageVersion.getGeneralPackage()).thenReturn(mockPackage);
        when(mockPackageVersion.getArchitecture()).thenReturn(mockArchitecture);
View Full Code Here

        when(mockList.size()).thenReturn(1);
        final PackageVersion mockPackageVersion = mock(PackageVersion.class);
        when(mockList.get(eq(0))).thenReturn(mockPackageVersion);

        when(mockPackageVersion.getId()).thenReturn(0);
        ContentManagerLocal mockContentManager = mock(ContentManagerLocal.class);
        when(mockContentManager.persistPackageVersion(any(PackageVersion.class))).thenAnswer(
            new Answer<PackageVersion>() {
                public PackageVersion answer(InvocationOnMock invocation) throws Throwable {
                    Object[] args = invocation.getArguments();
                    return (PackageVersion) args[0];
                }
View Full Code Here

        TransactionManager tx = getTransactionManager();
        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);

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

TOP

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

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.