Package org.rhq.enterprise.server.content

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


    public void testCanDownloadScript() throws Exception {
        RhqFacade rhqFacade = mock(RhqFacade.class);

        RepoManagerRemote repoManager = mock(RepoManagerRemote.class);
        ContentManagerRemote contentManager = mock(ContentManagerRemote.class);
       
        when(rhqFacade.getProxy(RepoManagerRemote.class)).thenReturn(repoManager);
        when(rhqFacade.getProxy(ContentManagerRemote.class)).thenReturn(contentManager);
       
        when(repoManager.findReposByCriteria(any(Subject.class), any(RepoCriteria.class))).then(
            new Answer<List<Repo>>() {
                @Override
                public List<Repo> answer(InvocationOnMock invocation) throws Throwable {
                    RepoCriteria crit = (RepoCriteria) invocation.getArguments()[1];

                    //this is so wrong...
                    Field f = RepoCriteria.class.getDeclaredField("filterName");
                    f.setAccessible(true);
                    String name = (String) f.get(crit);

                    if (CORRECT_REPO_NAME.equals(name)) {
                        Repo repo = new Repo(CORRECT_REPO_NAME);
                        repo.setId(CORRECT_REPO_ID);

                        PageList<Repo> ret = new PageList<Repo>(PageControl.getUnlimitedInstance());
                        ret.add(repo);
                        return ret;
                    } else {
                        return new PageList<Repo>(PageControl.getUnlimitedInstance());
                    }
                }
            });
       
        when(contentManager.findPackagesWithLatestVersion(any(Subject.class), any(PackageCriteria.class))).then(
            new Answer<List<PackageAndLatestVersionComposite>>() {
                @Override
                public List<PackageAndLatestVersionComposite> answer(InvocationOnMock invocation) throws Throwable {
                    PackageCriteria crit = (PackageCriteria) invocation.getArguments()[1];
View Full Code Here


            if (!repos.iterator().hasNext()) {
                return null;
            }

            final ContentManagerRemote contentManager = rhqFacade.getProxy(ContentManagerRemote.class);

            for (Repo repo : repos) {
                final PackageCriteria pCrit = new PackageCriteria();
                pCrit.addFilterName(scriptName);
                pCrit.addFilterRepoId(repo.getId());

                //Use CriteriaQuery to automatically chunk/page through criteria query results
                CriteriaQueryExecutor<PackageAndLatestVersionComposite, PackageCriteria> pQueryExecutor = new CriteriaQueryExecutor<PackageAndLatestVersionComposite, PackageCriteria>() {
                    @Override
                    public PageList<PackageAndLatestVersionComposite> execute(PackageCriteria criteria) {
                        return contentManager.findPackagesWithLatestVersion(rhqFacade.getSubject(), pCrit);
                    }
                };

                CriteriaQuery<PackageAndLatestVersionComposite, PackageCriteria> pvs = new CriteriaQuery<PackageAndLatestVersionComposite, PackageCriteria>(
                    pCrit, pQueryExecutor);
View Full Code Here

            this.allProperties.put(o.getName(), o);
        }
    }

    private void initContent() {
        ContentManagerRemote contentManager = remoteClient.getProxy(ContentManagerRemote.class);
        List<PackageType> types = null;
        try {
            types = contentManager.findPackageTypes(remoteClient.getSubject(), resource.getResourceType().getName(),
                resource.getResourceType().getPlugin());

            for (PackageType packageType : types) {
                contentTypes.put(packageType.getName(), new ContentType(packageType));
            }
View Full Code Here

        public PackageType getPackageType() {
            return this.packageType;
        }

        public List<PackageVersion> getInstalledPackages() {
            ContentManagerRemote contentManager = remoteClient.getProxy(ContentManagerRemote.class);

            PackageVersionCriteria criteria = new PackageVersionCriteria();
            criteria.addFilterResourceId(resourceId);
            // criteria.addFilterPackageTypeId()  TODO ADD this when the filter is added

            return contentManager.findPackageVersionsByCriteria(remoteClient.getSubject(), criteria);
        }
View Full Code Here

            String packageVersion = "[sha256=" + sha + "]";

            InstalledPackage oldPackage = getBackingContent();

            ContentManagerRemote contentManager = remoteClient.getProxy(ContentManagerRemote.class);

            ContentUploader contentUploader = new ContentUploader(contentManager);
            String temporaryContentHandle = contentUploader.upload(file);

            PackageVersion pv = contentManager.createPackageVersionWithDisplayVersion(remoteClient.getSubject(),
                oldPackage.getPackageVersion().getGeneralPackage().getName(), oldPackage.getPackageVersion()
                    .getGeneralPackage().getPackageType().getId(), packageVersion, displayVersion, oldPackage
                    .getPackageVersion().getArchitecture().getId(), temporaryContentHandle);

            contentManager.deployPackagesWithNote(remoteClient.getSubject(), new int[] { resourceClientProxy.getId() },
                new int[] { pv.getId() }, "CLI deployment request");
        }
View Full Code Here

TOP

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

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.