Package org.rhq.enterprise.server.plugin.pc.content

Examples of org.rhq.enterprise.server.plugin.pc.content.ContentProviderPackageDetails


            // we didn't set up any mappings like that yet - this will be the first one
            PackageSyncReport report = new PackageSyncReport();
            ContentProviderPackageDetailsKey key = new ContentProviderPackageDetailsKey("testCreateContentSourceFoo",
                "testCreateContentSourceVer", packageType1.getName(), architecture1.getName(), resourceType1.getName(),
                resourceType1.getPlugin());
            ContentProviderPackageDetails details = new ContentProviderPackageDetails(key);
            details.setLocation("dummy-location");
            details.setMetadata("dummy-metadata".getBytes());
            details.addResourceVersion("1.0.0");
            details.addResourceVersion("2.0.0");
            report.addNewPackage(details);
            Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous;
            previous = new HashMap<ContentProviderPackageDetailsKey, PackageVersionContentSource>();

            // merge the report!
View Full Code Here


            // this report will add a mapping to PV->CS
            PackageSyncReport report = new PackageSyncReport();
            ContentProviderPackageDetailsKey key = new ContentProviderPackageDetailsKey("testARUFoo", "testARUVer",
                packageType1.getName(), architecture1.getName(), resourceType1.getName(), resourceType1.getPlugin());
            ContentProviderPackageDetails details = new ContentProviderPackageDetails(key);
            details.setLocation("dummy-location-aru");
            details.setFileSize(1234L); // lazy load is on, this should not matter
            report.addNewPackage(details);
            Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous;
            previous = new HashMap<ContentProviderPackageDetailsKey, PackageVersionContentSource>();

            // ADD: merge the report!
            results = contentSourceManager.mergePackageSyncReport(contentSource, repo, report, previous, results);
            assert results != null;

            // see the package version has been assigned to the content source
            inCS = contentSourceManager.getPackageVersionsFromContentSource(overlord, contentSourceId, pc);
            assert inCS != null;
            assert inCS.size() == 1 : inCS;

            // confirm that we didn't load the bits yet
            List<PackageVersionContentSource> unloaded;
            unloaded = contentSourceManager.getUnloadedPackageVersionsFromContentSourceInRepo(overlord,
                contentSourceId, repoId, pc);
            assert unloaded != null;
            assert unloaded.size() == 1;

            // check the count
            long pvcscount = contentSourceManager.getPackageVersionCountFromContentSource(overlord, contentSourceId);
            assert (pvcscount == 1) : "-->" + pvcscount;

            // this is the new one we just added - we'll pass this to our next merge as the previous state
            PackageVersionContentSource addedPVCS = unloaded.get(0);
            assert addedPVCS.getPackageVersionContentSourcePK().getPackageVersion().getFileSize() == 1234L;
            previous.put(key, addedPVCS);

            System.out.println("content source merge ADD works!");

            // create a new report that updates the one we just added
            report = new PackageSyncReport();
            details.setFileSize(9999L);
            report.addUpdatedPackage(details);

            // UPDATE: merge the report!
            results = contentSourceManager.mergePackageSyncReport(contentSource, repo, report, previous, results);
            assert results != null;
View Full Code Here

            // this report will add a mapping to PV->CS
            PackageSyncReport report = new PackageSyncReport();
            ContentProviderPackageDetailsKey key = new ContentProviderPackageDetailsKey("testARU2Foo", "testARU2Ver",
                packageType1.getName(), architecture1.getName(), resourceType1.getName(), resourceType1.getPlugin());
            ContentProviderPackageDetails details = new ContentProviderPackageDetails(key);
            details.setLocation("dummy-location-aru");
            report.addNewPackage(details);
            Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous;
            previous = new HashMap<ContentProviderPackageDetailsKey, PackageVersionContentSource>();

            // ADD: merge the report!
View Full Code Here

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

           
            ContentProviderPackageDetailsKey key;
            key = new ContentProviderPackageDetailsKey(p.getName(), pv.getVersion(), p.getPackageType().getName(), pv
                .getArchitecture().getName(), resourceTypeName, resourceTypePlugin);

            ContentProviderPackageDetails details = new ContentProviderPackageDetails(key);
            details.setClassification(pv.getGeneralPackage().getClassification());
            details.setDisplayName(pv.getDisplayName());
            details.setDisplayVersion(pv.getDisplayVersion());
            details.setExtraProperties(pv.getExtraProperties());
            details.setFileCreatedDate(pv.getFileCreatedDate());
            details.setFileName(pv.getFileName());
            details.setFileSize(pv.getFileSize());
            details.setLicenseName(pv.getLicenseName());
            details.setLicenseVersion(pv.getLicenseVersion());
            details.setLocation(pvcs.getLocation());
            details.setLongDescription(pv.getLongDescription());
            details.setMD5(pv.getMD5());
            details.setMetadata(pv.getMetadata());
            details.setSHA256(pv.getSHA256());
            details.setShortDescription(pv.getShortDescription());

            allDetails.add(details);
            keyPVCSMap.put(key, pvcs);
        }
    }
View Full Code Here

            .getSupportedPackageType().packageTypeName;
        assert "Mazzresource-type-name".equals(fullDetails.getSupportedPackageType().resourceTypeName) : fullDetails
            .getSupportedPackageType().resourceTypeName;
        assert "Mazzresource-type-plugin".equals(fullDetails.getSupportedPackageType().resourceTypePluginName) : fullDetails
            .getSupportedPackageType().resourceTypePluginName;
        ContentProviderPackageDetails cspd = fullDetails.getContentSourcePackageDetails();
        assert "Mazzarchitecture-name".equals(cspd.getArchitectureName()) : cspd.getArchitectureName();
        assert "Mazzclassification".equals(cspd.getClassification()) : cspd.getClassification();
        assert "Mazzdisplay-name".equals(cspd.getDisplayName()) : cspd.getDisplayName();
        assert "Mazzdisplay-version".equals(cspd.getDisplayVersion()) : cspd.getDisplayVersion();
        assert "456".equals(cspd.getFileCreatedDate().toString()) : cspd.getFileCreatedDate();
        assert "Mazzfile-name".equals(cspd.getFileName()) : cspd.getFileName();
        assert "123".equals(cspd.getFileSize().toString()) : cspd.getFileSize();
        assert "Mazzlicense-name".equals(cspd.getLicenseName()) : cspd.getLicenseName();
        assert "Mazzlicense-version".equals(cspd.getLicenseVersion()) : cspd.getLicenseVersion();
        assert "Mazzlocation".equals(cspd.getLocation()) : cspd.getLocation();
        assert "Mazzlong-description".equals(cspd.getLongDescription()) : cspd.getLongDescription();
        assert "Mazzmd5".equals(cspd.getMD5()) : cspd.getMD5();
        assert "Mazzmetadata".equals(new String(cspd.getMetadata())) : new String(cspd.getMetadata());
        assert "Mazzname".equals(cspd.getName()) : cspd.getName();
        assert "Mazzpackage-type-name".equals(cspd.getPackageTypeName()) : cspd.getPackageTypeName();
        assert "Mazzsha256".equals(cspd.getSHA256()) : cspd.getSHA256();
        assert "Mazzshort-description".equals(cspd.getShortDescription()) : cspd.getShortDescription();
        assert ("[sha256=" + cspd.getSHA256() + "]").equals(cspd.getVersion()) : cspd.getVersion();
        assert cspd.getResourceVersions().contains("Mazzresource-version1") : cspd.getResourceVersions();
        assert cspd.getResourceVersions().contains("Mazzresource-version2") : cspd.getResourceVersions();

        Configuration extra = cspd.getExtraProperties();
        PropertySimple firstsimple = extra.getSimple("firstsimple");
        PropertySimple secondsimple = extra.getSimple("secondsimple");
        PropertyList firstlist = extra.getList("firstlist");
        PropertyList anotherlist = extra.getList("anotherlist");
        PropertyMap firstmap = extra.getMap("firstmap");
        PropertyList list_o_maps = extra.getList("list-o-maps");
        assert firstsimple != null;
        assert secondsimple != null;
        assert firstlist != null;
        assert anotherlist != null;
        assert firstmap != null;
        assert list_o_maps != null;

        assert "First Simple".equals(firstsimple.getStringValue()) : firstsimple.getStringValue();
        assert "Second Simple".equals(secondsimple.getStringValue()) : secondsimple.getStringValue();

        List<Property> list = firstlist.getList();
        assert 3 == list.size() : list;
        assert "First List #1".equals(((PropertySimple) list.get(0)).getStringValue()) : list;
        assert "First List #2".equals(((PropertySimple) list.get(1)).getStringValue()) : list;
        assert "First List #3".equals(((PropertySimple) list.get(2)).getStringValue()) : list;

        list = anotherlist.getList();
        assert 3 == list.size() : list;
        assert "Another List #1".equals(((PropertySimple) list.get(0)).getStringValue()) : list;
        assert "Another List #2".equals(((PropertySimple) list.get(1)).getStringValue()) : list;
        assert "Another List #3".equals(((PropertySimple) list.get(2)).getStringValue()) : list;

        Map<String, Property> map = firstmap.getMap();
        assert 3 == map.size() : map;
        assert "First Map #1".equals(((PropertySimple) map.get("firstmap1")).getStringValue()) : map;
        assert "First Map #2".equals(((PropertySimple) map.get("firstmap2")).getStringValue()) : map;
        assert "First Map #3".equals(((PropertySimple) map.get("firstmap3")).getStringValue()) : map;

        list = list_o_maps.getList();
        assert 2 == list.size();
        PropertyMap propmap1 = (PropertyMap) list.get(0);
        PropertyMap propmap2 = (PropertyMap) list.get(1);
        assert "map".equals(propmap1.getName());
        assert "map".equals(propmap2.getName());
        Map<String, Property> map1 = propmap1.getMap();
        Map<String, Property> map2 = propmap2.getMap();
        assert 2 == map1.size() : map1;
        assert 2 == map2.size() : map2;
        assert "List-o-Map #1 value 1".equals(((PropertySimple) map1.get("map1value1")).getStringValue()) : map1;
        assert "List-o-Map #1 value 2".equals(((PropertySimple) map1.get("map1value2")).getStringValue()) : map1;
        assert "List-o-Map #2 value 1".equals(((PropertySimple) map2.get("map2value1")).getStringValue()) : map2;
        assert "List-o-Map #2 value 2".equals(((PropertySimple) map2.get("map2value2")).getStringValue()) : map2;

        //// second package

        details = results.get("WOTGORILLAlocation");
        assert details != null : "missing details";
        assert details instanceof FullRemotePackageInfo : "Bad class=" + details.getClass();
        fullDetails = (FullRemotePackageInfo) details;
        assert "WOTGORILLAlocation".equals(fullDetails.getLocation()) : fullDetails.getLocation();
        assert null == fullDetails.getSHA256() : fullDetails.getSHA256();
        assert new URL("http://root/url/WOTGORILLAlocation").equals(fullDetails.getUrl()) : fullDetails.getUrl();
        assert "WOTGORILLAarchitecture-name".equals(fullDetails.getSupportedPackageType().architectureName) : fullDetails
            .getSupportedPackageType().architectureName;
        assert "WOTGORILLApackage-type-name".equals(fullDetails.getSupportedPackageType().packageTypeName) : fullDetails
            .getSupportedPackageType().packageTypeName;
        assert "WOTGORILLAresource-type-name".equals(fullDetails.getSupportedPackageType().resourceTypeName) : fullDetails
            .getSupportedPackageType().resourceTypeName;
        assert "WOTGORILLAresource-type-plugin".equals(fullDetails.getSupportedPackageType().resourceTypePluginName) : fullDetails
            .getSupportedPackageType().resourceTypePluginName;
        cspd = fullDetails.getContentSourcePackageDetails();
        assert "WOTGORILLAarchitecture-name".equals(cspd.getArchitectureName()) : cspd.getArchitectureName();
        assert null == cspd.getClassification() : cspd.getClassification();
        assert null == cspd.getDisplayName() : cspd.getDisplayName();
        assert null == cspd.getDisplayVersion() : cspd.getDisplayVersion();
        assert null == cspd.getFileCreatedDate() : cspd.getFileCreatedDate();
        assert null == cspd.getFileName() : cspd.getFileName();
        assert null == cspd.getFileSize() : cspd.getFileSize();
        assert null == cspd.getLicenseName() : cspd.getLicenseName();
        assert null == cspd.getLicenseVersion() : cspd.getLicenseVersion();
        assert "WOTGORILLAlocation".equals(cspd.getLocation()) : cspd.getLocation();
        assert null == cspd.getLongDescription() : cspd.getLongDescription();
        assert null == cspd.getMD5() : cspd.getMD5();
        assert null == cspd.getMetadata() : cspd.getMetadata();
        assert "WOTGORILLAname".equals(cspd.getName()) : cspd.getName();
        assert "WOTGORILLApackage-type-name".equals(cspd.getPackageTypeName()) : cspd.getPackageTypeName();
        assert null == cspd.getSHA256() : cspd.getSHA256();
        assert null == cspd.getShortDescription() : cspd.getShortDescription();
        assert "[sha256=null]".equals(cspd.getVersion()) : cspd.getVersion();
        assert 0 == cspd.getResourceVersions().size() : cspd.getResourceVersions();
    }
View Full Code Here

        parser.parseResults(rssDocument3, report, null);

        Set<ContentProviderPackageDetails> newPackages = report.getNewPackages();

        for (Iterator iterator = newPackages.iterator(); iterator.hasNext();) {
            ContentProviderPackageDetails contentSourcePackageDetails = (ContentProviderPackageDetails) iterator.next();
            String installIns = new String(contentSourcePackageDetails.getMetadata());

            assert installIns.startsWith("<?xml version=\"1.0\"?>");
            installIns = installIns.substring(21).trim();
            assert installIns.startsWith("<process-definition name=\"process\">") ||
                installIns.startsWith("<!DOCTYPE process-definition [ <!ENTITY handler_A")
View Full Code Here

     * @throws Exception if the sync fails
     */
    protected void syncPackage(PackageSyncReport report, List<ContentProviderPackageDetails> packages,
        RemotePackageInfo rpi) throws Exception {

        ContentProviderPackageDetails details = createPackage(rpi);
        if (details != null) {
            ContentProviderPackageDetails existing = findPackage(packages, details);
            if (existing == null) {
                report.addNewPackage(details);
            } else {
                packages.remove(existing); // it still exists, remove it from our list
                if (details.getFileCreatedDate().compareTo(existing.getFileCreatedDate()) > 0) {
                    report.addUpdatedPackage(details);
                }
            }
        } else {
            // file does not match any filter and is therefore an unknown type - ignore it
View Full Code Here

        SupportedPackageType supportedPackageType = determinePackageType(rpi);
        if (supportedPackageType == null) {
            return null; // we can't handle this file - it is an unknown/unsupported package type
        }

        ContentProviderPackageDetails pkg = null;

        if (rpi instanceof FullRemotePackageInfo) {
            pkg = ((FullRemotePackageInfo) rpi).getContentSourcePackageDetails();
        }

        if (pkg == null) {
            String sha256 = rpi.getSHA256();
            String name = new File(rpi.getLocation()).getName();
            String version = "[sha256=" + sha256 + "]";
            String packageTypeName = supportedPackageType.packageTypeName;
            String architectureName = supportedPackageType.architectureName;
            String resourceTypeName = supportedPackageType.resourceTypeName;
            String resourceTypePluginName = supportedPackageType.resourceTypePluginName;

            ContentProviderPackageDetailsKey key = new ContentProviderPackageDetailsKey(name, version, packageTypeName,
                architectureName, resourceTypeName, resourceTypePluginName);
            pkg = new ContentProviderPackageDetails(key);

            URLConnection urlConn = rpi.getUrl().openConnection();
            pkg.setFileCreatedDate(urlConn.getLastModified());
            pkg.setFileSize(new Long(urlConn.getContentLength()));
            pkg.setDisplayName(name);
            pkg.setFileName(name);
            pkg.setSHA256(sha256);
            pkg.setLocation(rpi.getLocation());
            pkg.setShortDescription(null);
        }

        return pkg;
    }
View Full Code Here

                if (file.getName().equals(repoName)) {

                    for (File filePackage : file.listFiles()) {
                        if (!filePackage.isDirectory()) {
                            ContentProviderPackageDetails details = createPackage(filePackage);
                            if (details != null) {
                                ContentProviderPackageDetails existing = findPackage(packages, details);
                                if (existing == null) {
                                    report.addNewPackage(details);
                                } else {
                                    packages.remove(existing); // it still exists, remove it from our list
                                    if (details.getFileCreatedDate().compareTo(existing.getFileCreatedDate()) > 0) {
                                        report.addUpdatedPackage(details);
                                    }
                                }
                            }
                            else {
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.plugin.pc.content.ContentProviderPackageDetails

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.